summaryrefslogtreecommitdiff
path: root/docs/examples/swing/SwingApp.scala
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/swing/SwingApp.scala')
-rw-r--r--docs/examples/swing/SwingApp.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/examples/swing/SwingApp.scala b/docs/examples/swing/SwingApp.scala
new file mode 100644
index 0000000000..b3fe7447ef
--- /dev/null
+++ b/docs/examples/swing/SwingApp.scala
@@ -0,0 +1,29 @@
+package examples.swing
+
+import swing._
+import swing.event._
+
+object SwingApp extends SimpleSwingApplication {
+ def top = new MainFrame {
+ title = "SwingApp"
+ var numclicks = 0
+ object label extends Label {
+ val prefix = "Number of button clicks: "
+ text = prefix + "0 "
+ listenTo(button)
+ reactions += {
+ case ButtonClicked(button) =>
+ numclicks = numclicks + 1
+ text = prefix + numclicks
+ }
+ }
+ object button extends Button {
+ text = "I am a button"
+ }
+ contents = new FlowPanel {
+ contents.append(button, label)
+ border = Swing.EmptyBorder(5, 5, 5, 5)
+ }
+ }
+}
+