Skip to content

Commit acee55a

Browse files
authored
Merge pull request #87 from Sciss/work
v2.1.0
2 parents 3566a92 + 6658413 commit acee55a

File tree

3 files changed

+72
-7
lines changed

3 files changed

+72
-7
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The widget class hierarchy loosely resembles that of Java Swing. The main differ
1616
In scala-swing, components that can have child components extend the Container trait.
1717
- Layout managers and panels are coupled. There is no way to exchange the layout manager
1818
of a panel. As a result, the layout constraints for widgets can be typed.
19-
(Note that you gain more type-safety and don't loose much flexibility here. Besides
19+
(Note that you gain more type-safety and do not loose much flexibility here. Besides
2020
being not a common operation, exchanging the layout manager of a panel in Java
2121
Swing almost always leads to exchanging the layout constraints for every of the panel's
2222
child component. In the end, it is not more work to move all children to a newly created
@@ -25,8 +25,8 @@ The widget class hierarchy loosely resembles that of Java Swing. The main differ
2525
collection. The typical usage style is to create anonymous subclasses of the widgets to
2626
customize their properties, and nest children and event reactions.
2727
- The scala-swing event system follows a different approach than the underlying Java system.
28-
Instead of add event listeners with a particular interface (such as `java.awt.ActionListener`),
29-
a `Reactor` instances announces the interest in receiving events by calling `listenTo` for
28+
Instead of adding event listeners with a particular interface (such as `java.awt.ActionListener`),
29+
a `Reactor` instance announces the interest in receiving events by calling `listenTo` for
3030
a `Publisher`. Publishers are also reactors and listen to themselves per default as a convenience.
3131
A reactor contains an object `reactions` which serves as a convenient place to register observers
3232
by adding partial functions that pattern match for any event that the observer is interested in.
@@ -117,3 +117,4 @@ at [http://www.scala-lang.org/documentation/api.html](http://www.scala-lang.org/
117117
## Current Work
118118

119119
Current changes are being made on the `work` branch.
120+
Last published version is found on the `main` branch.

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ scalaModuleSettings
44

55
name := "scala-swing"
66

7-
version := "2.1.0-SNAPSHOT"
7+
version := "2.1.0"
88

99
scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature")
1010

src/main/scala/scala/swing/package.scala

+67-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,73 @@
88

99
package scala
1010

11-
/**
12-
* Useful imports that do not have wrappers.
13-
*/
11+
/** Scala-swing is a graphical user interface library that will wrap most of Java Swing
12+
* for Scala in a straightforward manner.
13+
*
14+
* ==Overview==
15+
*
16+
* The widget class hierarchy loosely resembles that of Java Swing.
17+
* The main differences are:
18+
*
19+
* - In Java Swing all components are containers per default. This does not make much sense for a number
20+
* of components, like [[scala.swing.TextField]], [[scala.swing.CheckBox]], [[scala.swing.RadioButton]],
21+
* and so on. Our guess is that this architecture
22+
* was chosen because Java lacks multiple inheritance. In scala-swing, components that can have child
23+
* components extend the [[scala.swing.Container]] trait.
24+
* - Layout managers and panels are coupled. There is no way to exchange the layout manager of a panel.
25+
* As a result, the layout constraints for widgets can be typed. (Note that you gain more type-safety
26+
* and do not loose much flexibility here. Besides being not a common operation, exchanging the layout
27+
* manager of a panel in Java Swing almost always leads to exchanging the layout constraints for every
28+
* of the panel's child component. In the end, it is not more work to move all children to a newly
29+
* created panel.)
30+
* - Widget hierarchies are built by adding children to their parent container's contents collection.
31+
* The typical usage style is to create anonymous subclasses of the widgets to customize their
32+
* properties, and nest children and event reactions.
33+
* - The scala-swing event system follows a different approach than the underlying Java system. Instead
34+
* of adding event listeners with a particular interface (such as `java.awt.ActionListener`),
35+
* a [[scala.swing.Reactor]]
36+
* instance announces the interest in receiving events by calling `listenTo` for a [[scala.swing.Publisher]].
37+
* Publishers
38+
* are also reactors and listen to themselves per default as a convenience. A reactor contains an object
39+
* `reactions` which serves as a convenient place to register observers by adding partial functions that
40+
* pattern match for any event that the observer is interested in. This is shown in the examples section
41+
* below.
42+
* - For more details see [[https://github.com/scala/scala-swing/blob/work/docs/SIP-8.md SIP-8]].
43+
*
44+
* Scala-swing comprises two main packages:
45+
*
46+
* - `scala.swing`: All widget classes and traits.
47+
* - `scala.swing.event`: The event hierarchy.
48+
*
49+
* This package object contains useful type aliases that do not have wrappers.
50+
*
51+
* ==Examples==
52+
*
53+
* The following example shows how to plug components and containers together and react to a
54+
* mouse click on a button:
55+
*
56+
* {{{
57+
* import scala.swing._
58+
*
59+
* new Frame {
60+
* title = "Hello world"
61+
*
62+
* contents = new FlowPanel {
63+
* contents += new Label("Launch rainbows:")
64+
* contents += new Button("Click me") {
65+
* reactions += {
66+
* case event.ButtonClicked(_) =>
67+
* println("All the colours!")
68+
* }
69+
* }
70+
* }
71+
*
72+
* pack()
73+
* centerOnScreen()
74+
* open()
75+
* }
76+
* }}}
77+
*/
1478
package object swing {
1579
type Point = java.awt.Point
1680
type Dimension = java.awt.Dimension

0 commit comments

Comments
 (0)