Packages

  • package root
    Definition Classes
    root
  • package scala
    Definition Classes
    root
  • package swing

    Scala-swing is a graphical user interface library that will wrap most of Java Swing for Scala in a straightforward manner.

    Scala-swing is a graphical user interface library that will wrap most of Java Swing for Scala in a straightforward manner.

    Overview

    The widget class hierarchy loosely resembles that of Java Swing. The main differences are:

    • In Java Swing all components are containers per default. This does not make much sense for a number of components, like scala.swing.TextField, scala.swing.CheckBox, scala.swing.RadioButton, and so on. Our guess is that this architecture was chosen because Java lacks multiple inheritance. In scala-swing, components that can have child components extend the scala.swing.Container trait.
    • Layout managers and panels are coupled. There is no way to exchange the layout manager of a panel. As a result, the layout constraints for widgets can be typed. (Note that you gain more type-safety and do not loose much flexibility here. Besides being not a common operation, exchanging the layout manager of a panel in Java Swing almost always leads to exchanging the layout constraints for every of the panel's child component. In the end, it is not more work to move all children to a newly created panel.)
    • Widget hierarchies are built by adding children to their parent container's contents collection. The typical usage style is to create anonymous subclasses of the widgets to customize their properties, and nest children and event reactions.
    • The scala-swing event system follows a different approach than the underlying Java system. Instead of adding event listeners with a particular interface (such as java.awt.ActionListener), a scala.swing.Reactor instance announces the interest in receiving events by calling listenTo for a scala.swing.Publisher. Publishers are also reactors and listen to themselves per default as a convenience. A reactor contains an object reactions which serves as a convenient place to register observers by adding partial functions that pattern match for any event that the observer is interested in. This is shown in the examples section below.
    • For more details see SIP-8.

    Scala-swing comprises two main packages:

    • scala.swing: All widget classes and traits.
    • scala.swing.event: The event hierarchy.

    This package object contains useful type aliases that do not have wrappers.

    Examples

    The following example shows how to plug components and containers together and react to a mouse click on a button:

    import scala.swing._
    
    new Frame {
      title = "Hello world"
    
      contents = new FlowPanel {
        contents += new Label("Launch rainbows:")
        contents += new Button("Click me") {
          reactions += {
            case event.ButtonClicked(_) =>
              println("All the colours!")
          }
        }
      }
    
      pack()
      centerOnScreen()
      open()
    }
    Definition Classes
    scala
  • object Action
    Definition Classes
    swing
  • NoAction
  • Trigger

case object NoAction extends Action with Product with Serializable

Special action that has an empty title and all default properties and does nothing. Use this as a "null action", i.e., to tell components that they do not have any associated action. A component may then obtain its properties from its direct members instead of from its action. In Java Swing, one would use null instead of a designated action.

Linear Supertypes
java.io.Serializable, Product, Equals, Action, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NoAction
  2. Serializable
  3. Product
  4. Equals
  5. Action
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def accelerator: Option[KeyStroke]

    For menus.

    For menus.

    Definition Classes
    Action
  5. def accelerator_=(k: Option[KeyStroke]): Unit
    Definition Classes
    Action
  6. def apply(): Unit
    Definition Classes
    NoActionAction
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  9. def enabled: Boolean

    For all components.

    For all components.

    Definition Classes
    Action
  10. def enabled_=(b: Boolean): Unit
    Definition Classes
    Action
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def icon: Icon

    None if large icon and small icon are not equal.

    None if large icon and small icon are not equal.

    Definition Classes
    Action
  16. def icon_=(i: Icon): Unit
    Definition Classes
    Action
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def longDescription: String

    Can be used for status bars, for example.

    Can be used for status bars, for example.

    Definition Classes
    Action
  19. def longDescription_=(t: String): Unit
    Definition Classes
    Action
  20. def mnemonic: Int

    Default: java.awt.event.KeyEvent.VK_UNDEFINED, i.e., no mnemonic key.

    Default: java.awt.event.KeyEvent.VK_UNDEFINED, i.e., no mnemonic key. For all buttons and thus menu items.

    Definition Classes
    Action
  21. def mnemonic_=(m: Int): Unit
    Definition Classes
    Action
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. lazy val peer: javax.swing.Action
    Definition Classes
    Action
  26. def productElementName(n: Int): String
    Definition Classes
    Product
  27. def productElementNames: Iterator[String]
    Definition Classes
    Product
  28. def smallIcon: Icon
    Definition Classes
    Action
  29. def smallIcon_=(i: Icon): Unit
    Definition Classes
    Action
  30. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  31. def text: String

    Gets the NAME property.

    Gets the NAME property.

    Definition Classes
    Action
  32. def text_=(t: String): Unit

    Sets the NAME property.

    Sets the NAME property.

    Definition Classes
    Action
  33. def title: String

    An alias for text.

    An alias for text. This is kept for backwards compatibility.

    Definition Classes
    Action
    See also

    text

  34. def title_=(t: String): Unit

    An alias for text_=.

    An alias for text_=. This is kept for backwards compatibility.

    Definition Classes
    Action
  35. def toolTip: String

    For all components.

    For all components.

    Definition Classes
    Action
  36. def toolTip_=(t: String): Unit
    Definition Classes
    Action
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from java.io.Serializable

Inherited from Product

Inherited from Equals

Inherited from Action

Inherited from AnyRef

Inherited from Any

Ungrouped