diff options
Diffstat (limited to 'docs/examples/swing/CountButton.scala')
-rw-r--r-- | docs/examples/swing/CountButton.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/examples/swing/CountButton.scala b/docs/examples/swing/CountButton.scala new file mode 100644 index 0000000000..5fb14681d6 --- /dev/null +++ b/docs/examples/swing/CountButton.scala @@ -0,0 +1,30 @@ +package examples.swing + +import scala.swing._ +import scala.swing.event._ + +object CountButton extends SimpleSwingApplication { + 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 + } + } + } +} |