Anonymous user
Simple windowed application: Difference between revisions
→{{header|Scala}}
m (→{{header|Objective-C}}: modernize) |
|||
Line 1,614:
=={{header|Scala}}==
[[Category:Scala Implementations]]
{{libheader|Scala}}
import scala.swing.event._▼
<lang Scala>import scala.swing.{ BorderPanel, Button, Label, MainFrame, SimpleSwingApplication }
object SimpleApp extends SimpleSwingApplication {
def top = new MainFrame {
var nClicks = 0▼
val button = new Button {▼
text = "There have been no clicks yet"▼
contents = new BorderPanel {
▲ var nClicks = 0
▲ val (button, label) = (new Button { text = "click me" },
▲ new Label { text = "There have been no clicks yet" })
layout(button) = BorderPanel.Position.South
layout(label) = BorderPanel.Position.Center
listenTo(button)▼
case ButtonClicked(_) =>▼
nClicks += 1
▲ listenTo(button)
▲ case ButtonClicked(_) =>
▲ nClicks += 1
▲ label.text = "There have been %d clicks" format nClicks
}
}
|