import javafx.scene.control.CheckBox; import javafx.scene.input.MouseEvent; import javafx.scene.control.TextBox; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.control.Label; /* * converter.fx * * Created on 28-Jan-2010, 21:16:57 */ /** * @author Administrator */ // place your code here var n1; var n2; var n3; var n1i; var n2i; var n3i; var n4i; var n5=TextBox { text: "isi nilai yang ingin di konversi" columns: 20 selectOnFocus: true }; var n4=CheckBox { text: "Celcius" allowTriState: false selected: false onMouseClicked: function (e: MouseEvent): Void { n1i=Double.parseDouble(n5.text); n1=n1i; n2=n1i*((9/5)+32); n3=(n1i+273.15); n2i=Double.toString(n1); n3i=Double.toString(n2); n4i=Double.toString(n3); } }; var n6=CheckBox { text: "Farenheit!" allowTriState: false selected: false onMouseClicked: function (e: MouseEvent): Void { n1i=Double.parseDouble(n5.text); n1=(n1i-32)*5/9; n2=n1i; n3=(n1i+459.67)*5/9; n2i=Double.toString(n1); n3i=Double.toString(n2); n4i=Double.toString(n3); } }; var n7=CheckBox { text: "Kelvin!" allowTriState: true selected: false onMouseClicked: function (e: MouseEvent): Void { n1i=Double.parseDouble(n5.text); n1=(n1i-273.15); n2=((n1i*(9/5))-459.67); n3=n1i; n2i=Double.toString(n1); n3i=Double.toString(n2); n4i=Double.toString(n3); } }; var n8=TextBox { text: bind n2i columns: 12 selectOnFocus: true } var n9=TextBox { text: bind n3i columns: 12 selectOnFocus: true } var n10=TextBox { text: bind n4i columns: 12 selectOnFocus: true } var n11=Label { text: "Celcius" } var n12=Label { text: "Fahrenheit" } var n13=Label { text: "Kelvin" } Stage { title : "Termometer Converter" scene: Scene { width: 500 height: 200 fill:Color.LIGHTBLUE; content: [ VBox { spacing:10 content: [ HBox { spacing:10 translateY:20 content: [ n5,n4,n6,n7 ] }, HBox { spacing:10 translateY:30 content: [ n11,n8,n12,n9,n13,n10 ] } ] } ] } }