summaryrefslogtreecommitdiff
path: root/src/swing
diff options
context:
space:
mode:
authorIngo Maier <ingo.maier@epfl.ch>2008-08-05 08:14:54 +0000
committerIngo Maier <ingo.maier@epfl.ch>2008-08-05 08:14:54 +0000
commit4d721eabbdbd49f4dbc62d32b4d4a2d0cab0f0ea (patch)
treef8f465abee021bed4b0468d6b56729508bbdd774 /src/swing
parent928575966029f6f76911ccd239fc00f76fb690bc (diff)
downloadscala-4d721eabbdbd49f4dbc62d32b4d4a2d0cab0f0ea.tar.gz
scala-4d721eabbdbd49f4dbc62d32b4d4a2d0cab0f0ea.tar.bz2
scala-4d721eabbdbd49f4dbc62d32b4d4a2d0cab0f0ea.zip
Minor changes, added button demo from the book
Diffstat (limited to 'src/swing')
-rwxr-xr-xsrc/swing/scala/swing/test/ButtonApp.scala7
-rw-r--r--src/swing/scala/swing/test/CountButton.scala30
-rw-r--r--src/swing/scala/swing/test/UIDemo.scala1
3 files changed, 34 insertions, 4 deletions
diff --git a/src/swing/scala/swing/test/ButtonApp.scala b/src/swing/scala/swing/test/ButtonApp.scala
index 577f3984a6..9d8fcb04e3 100755
--- a/src/swing/scala/swing/test/ButtonApp.scala
+++ b/src/swing/scala/swing/test/ButtonApp.scala
@@ -1,9 +1,10 @@
package scala.swing.test
-import swing._, swing.event._
+import swing._
+import swing.event._
-object MyApp extends SimpleGUIApplication {
- def top = new Frame {
+object ButtonApp extends SimpleGUIApplication {
+ def top = new MainFrame {
title = "My Frame"
contents = new GridPanel(2, 2) {
hGap = 3
diff --git a/src/swing/scala/swing/test/CountButton.scala b/src/swing/scala/swing/test/CountButton.scala
new file mode 100644
index 0000000000..d211bbe15e
--- /dev/null
+++ b/src/swing/scala/swing/test/CountButton.scala
@@ -0,0 +1,30 @@
+package scala.swing.test
+
+import scala.swing._
+import scala.swing.event._
+
+object CountButton extends SimpleGUIApplication {
+ def top = new MainFrame {
+ title = "My Frame"
+ contents = new GridPanel(2, 2) {
+ hGap = 3
+ vGap = 3
+ val button = new Button {
+ text = "Press Me!"
+ }
+ contents += button
+ val label = new Label {
+ text = "No button clicks registered"
+ }
+ contents += label
+
+ listenTo(button)
+ var nclicks = 0
+ reactions += {
+ case ButtonClicked(b) =>
+ nclicks += 1
+ label.text = "Number of button clicks: "+nclicks
+ }
+ }
+ }
+}
diff --git a/src/swing/scala/swing/test/UIDemo.scala b/src/swing/scala/swing/test/UIDemo.scala
index f92569c187..880438f97f 100644
--- a/src/swing/scala/swing/test/UIDemo.scala
+++ b/src/swing/scala/swing/test/UIDemo.scala
@@ -10,7 +10,6 @@ object UIDemo extends SimpleGUIApplication {
menuBar = new MenuBar
- import Views._
import Border._
val menu = new Menu("A Menu")