Created
February 24, 2011 21:53
-
-
Save hedefalk/842966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Temperature { | |
implicit def unboxText2Double(t: Text) = java.lang.Double.parseDouble(t.getText()) | |
implicit def convertDouble2String(d: Double) = d.toString | |
var fahrenheit: Text = null | |
var celsius: Text = null | |
def main(args: Array[String]): Unit = { | |
val window = shell("Demo!", | |
composite( | |
_.setLayout(new GridLayout(2, true)), | |
label("Fahrenheit"), | |
label("Celsius"), | |
text(fahrenheit = _, | |
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false)), | |
text(celsius = _, | |
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false)), | |
button( | |
"Fahrenheit => Celsius", | |
{ e: SelectionEvent => celsius.setText((5.0 / 9.0) * (fahrenheit - 32)) }), | |
button( | |
"Celsius -> Fahrenheit", | |
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false), | |
{ e: SelectionEvent => fahrenheit.setText((9.0 / 5.0) * celsius + 32) }))) | |
runEventLoop(window) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment