This page is no longer maintained — Please continue to the home page at www.scala-lang.org

New components to swing library

1 reply
Victor Mateus O...
Joined: 2009-02-09,
User offline. Last seen 42 years 45 weeks ago.
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
imaier
Joined: 2008-07-01,
User offline. Last seen 23 weeks 2 days ago.
Re: New components to swing library

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
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland