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 Reactions
    Definition Classes
    swing
  • Impl
  • StronglyReferenced
  • Wrapper

class Wrapper extends Reaction with StronglyReferenced with Proxy

Linear Supertypes
Proxy, StronglyReferenced, PartialFunction[Event, Unit], (Event) => Unit, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Wrapper
  2. Proxy
  3. StronglyReferenced
  4. PartialFunction
  5. Function1
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Wrapper(listener: Any)(r: Reaction)

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 andThen[C](k: PartialFunction[Unit, C]): PartialFunction[Event, C]
    Definition Classes
    PartialFunction
  5. def andThen[C](k: (Unit) => C): PartialFunction[Event, C]
    Definition Classes
    PartialFunction → Function1
  6. def apply(e: Event): Unit
    Definition Classes
    Wrapper → Function1
  7. def applyOrElse[A1 <: Event, B1 >: Unit](x: A1, default: (A1) => B1): B1
    Definition Classes
    PartialFunction
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. def compose[R](k: PartialFunction[R, Event]): PartialFunction[R, Unit]
    Definition Classes
    PartialFunction
  11. def compose[A](g: (A) => Event): (A) => Unit
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  12. def elementWise: ElementWiseExtractor[Event, Unit]
    Definition Classes
    PartialFunction
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(that: Any): Boolean
    Definition Classes
    Proxy → Any
  15. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  16. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def hashCode(): Int
    Definition Classes
    Proxy → Any
  18. def isDefinedAt(e: Event): Boolean
    Definition Classes
    Wrapper → PartialFunction
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def lift: (Event) => Option[Unit]
    Definition Classes
    PartialFunction
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. def orElse[A1 <: Event, B1 >: Unit](that: PartialFunction[A1, B1]): PartialFunction[A1, B1]
    Definition Classes
    PartialFunction
  25. def runWith[U](action: (Unit) => U): (Event) => Boolean
    Definition Classes
    PartialFunction
  26. def self: Any
    Definition Classes
    Wrapper → Proxy
  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def toString(): String
    Definition Classes
    Proxy → Any
  29. def unapply(a: Event): Option[Unit]
    Definition Classes
    PartialFunction
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Proxy

Inherited from StronglyReferenced

Inherited from PartialFunction[Event, Unit]

Inherited from (Event) => Unit

Inherited from AnyRef

Inherited from Any

Ungrouped