Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.*;
- import javafx.stage.*;
- import javafx.scene.layout.*;
- import javafx.scene.*;
- import javafx.scene.control.*;
- import javafx.geometry.*;
- public class SimpleCalculator extends Application {
- public static void main(String args[]) {
- launch(args);
- }
- public void start(Stage myStage) {
- myStage.setTitle("Simple Calculator");
- FlowPane rootNode = new FlowPane();
- rootNode.setAlignment(Pos.CENTER);
- Scene myScene = new Scene(rootNode, 300, 200);
- Label firstValueLabel = new Label("First Value:");
- Label secondValueLabel = new Label("Second Value:");
- Label thirdValueLabel = new Label("Third Value:");
- TextField firstValueField = new TextField("$");
- TextField secondValueField = new TextField("$");
- TextField thirdValueField = new TextField("$");
- firstValueField.setPrefColumnCount(14);
- secondValueField.setPrefColumnCount(14);
- thirdValueField.setPrefColumnCount(14);
- // we don't want the sum field to be editable
- thirdValueField.setEditable(false);
- Button btnCalculate = new Button("Calculate");
- rootNode.getChildren().addAll(firstValueLabel, firstValueField, secondValueLabel, secondValueField, thirdValueLabel, thirdValueField, btnCalculate);
- myStage.setScene(myScene);
- myStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement