- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
New components to swing library
Mon, 2009-02-09, 22:54
Hi,
I'm using scala to build a gui application. But, some components of swing isn't available in scala yet. (I know that i can use java, but i really prefer scala :-) )
By now, i just needed to do a JToolBar wrapper - In this case, i took MenuBar.scala as code base. But soon i'll need another components.
I'd know if there's some rules or tips to I follow, so i can send my wrappers to contribute with the scala swing library.
Here is the ToolBar.scala - strongly based on MenuBar (i think it has the same structure)
package scala.swing
import scala.collection.mutable._
import javax.swing._
/**
* A tool bar. Contains a number of buttons.
*
* @see javax.swing.JToolBar
*/
class ToolBar extends Component with SequentialContainer.Wrapper {
override lazy val peer: JToolBar = new JToolBar
def buttons: Seq[Button] = contents.filter(_.isInstanceOf[Button]).map(_.asInstanceOf[Button])
def addSeparator = peer.addSeparator();
}
I guess i can take ready components to guideline new others for most part of the cases. Right?
[]s
Victor
--
GNU/Linux user #5f5f5f - http://counter.li.org
I'm using scala to build a gui application. But, some components of swing isn't available in scala yet. (I know that i can use java, but i really prefer scala :-) )
By now, i just needed to do a JToolBar wrapper - In this case, i took MenuBar.scala as code base. But soon i'll need another components.
I'd know if there's some rules or tips to I follow, so i can send my wrappers to contribute with the scala swing library.
Here is the ToolBar.scala - strongly based on MenuBar (i think it has the same structure)
package scala.swing
import scala.collection.mutable._
import javax.swing._
/**
* A tool bar. Contains a number of buttons.
*
* @see javax.swing.JToolBar
*/
class ToolBar extends Component with SequentialContainer.Wrapper {
override lazy val peer: JToolBar = new JToolBar
def buttons: Seq[Button] = contents.filter(_.isInstanceOf[Button]).map(_.asInstanceOf[Button])
def addSeparator = peer.addSeparator();
}
I guess i can take ready components to guideline new others for most part of the cases. Right?
[]s
Victor
--
GNU/Linux user #5f5f5f - http://counter.li.org
Sorry for the late reply, I've been on vacation. New wrappers are always
welcome! I am not sure whether buttons belongs into ToolBar. You might
want to create a subclass ButtonToolBar, since toolbars do not
necessarily contain buttons only. I guess what you really want is to
filter separators and other fill components right?
I am happy to add your wrappers, once they are complete and we settle on
the design.
Ingo
Victor Mateus Oliveira wrote:
> Hi,
> /**
> * A tool bar. Contains a number of buttons.
> *
> * @see javax.swing.JToolBar
> */
> class ToolBar extends Component with SequentialContainer.Wrapper {
> override lazy val peer: JToolBar = new JToolBar
>
> def buttons: Seq[Button] =
> contents.filter(_.isInstanceOf[Button]).map(_.asInstanceOf[Button])
>
> def addSeparator = peer.addSeparator();
> }
>
>
>
> I guess i can take ready components to guideline new others for most
> part of the cases. Right?
>
> []s
> Victor
>