Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import javafx.application.*;
  2. import javafx.stage.*;
  3. import javafx.scene.layout.*;
  4. import javafx.scene.*;
  5. import javafx.scene.control.*;
  6. import javafx.geometry.*;
  7.  
  8. public class SimpleCalculator extends Application {
  9. public static void main(String args[]) {
  10. launch(args);
  11. }
  12.  
  13. public void start(Stage myStage) {
  14. myStage.setTitle("Simple Calculator");
  15. FlowPane rootNode = new FlowPane();
  16. rootNode.setAlignment(Pos.CENTER);
  17.  
  18. Scene myScene = new Scene(rootNode, 300, 200);
  19. Label firstValueLabel = new Label("First Value:");
  20. Label secondValueLabel = new Label("Second Value:");
  21. Label thirdValueLabel = new Label("Third Value:");
  22. TextField firstValueField = new TextField("$");
  23. TextField secondValueField = new TextField("$");
  24. TextField thirdValueField = new TextField("$");
  25. firstValueField.setPrefColumnCount(14);
  26. secondValueField.setPrefColumnCount(14);
  27. thirdValueField.setPrefColumnCount(14);
  28.  
  29. // we don't want the sum field to be editable
  30. thirdValueField.setEditable(false);
  31. Button btnCalculate = new Button("Calculate");
  32.  
  33. rootNode.getChildren().addAll(firstValueLabel, firstValueField, secondValueLabel, secondValueField, thirdValueLabel, thirdValueField, btnCalculate);
  34.  
  35. myStage.setScene(myScene);
  36. myStage.show();
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement