diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2011-12-07 21:52:20 +0100 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2011-12-07 22:09:04 +0100 |
commit | f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc (patch) | |
tree | 6d77a6dbbb3de69bc38a7e2d55a37596960675a0 /docs/examples/swing/CelsiusConverter.scala | |
parent | 332fec96e31840878bed41dd7b5314b97d8da7c2 (diff) | |
download | scala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.tar.gz scala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.tar.bz2 scala-f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc.zip |
Clean up standard/swing library by deprecating/moving code examples
Deprecate scala/xml/include/sax/Main.scala.
Move scala/swing/test/* to docs/examples.
Saves 160KB in scala-swing.jar.
Fixes SI-4627.
Diffstat (limited to 'docs/examples/swing/CelsiusConverter.scala')
-rw-r--r-- | docs/examples/swing/CelsiusConverter.scala | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/docs/examples/swing/CelsiusConverter.scala b/docs/examples/swing/CelsiusConverter.scala new file mode 100644 index 0000000000..b4a62fb366 --- /dev/null +++ b/docs/examples/swing/CelsiusConverter.scala @@ -0,0 +1,42 @@ +package examples.swing + +import swing._ +import event._ + +/** A GUI app to convert celsius to centigrade + */ +object CelsiusConverter extends SimpleSwingApplication { + def top = new MainFrame { + title = "Convert Celsius to Fahrenheit" + val tempCelsius = new TextField + val celsiusLabel = new Label { + text = "Celsius" + border = Swing.EmptyBorder(5, 5, 5, 5) + } + val convertButton = new Button { + text = "Convert"//new javax.swing.ImageIcon("c:\\workspace\\gui\\images\\convert.gif") + //border = Border.Empty(5, 5, 5, 5) + } + val fahrenheitLabel = new Label { + text = "Fahrenheit " + border = Swing.EmptyBorder(5, 5, 5, 5) + listenTo(convertButton, tempCelsius) + + def convert() { + val c = Integer.parseInt(tempCelsius.text) + val f = c * 9 / 5 + 32 + text = "<html><font color = red>"+f+"</font> Fahrenheit</html>" + } + + reactions += { + case ButtonClicked(_) | EditDone(_) => convert() + } + } + contents = new GridPanel(2,2) { + contents.append(tempCelsius, celsiusLabel, convertButton, fahrenheitLabel) + border = Swing.EmptyBorder(10, 10, 10, 10) + } + //defaultButton = Some(convertButton) + } +} + |