blob: 88464def2cba2120a7375a78426824332b7466d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package scala.swing
package 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
}
}
}
}
|