Monday 11 June 2012

Simple Calculator, JavaFX Style

package calculatorsimplu;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

/**
 *
 * @author Cristina
 */
public class CalculatorSimplu extends Application {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
   
    @Override
    public void start(Stage scena) {
               
        Label et1 = new Label("Primul numar:");
        TextField nr1 = new TextField();
        Label et2 = new Label("Al doilea numar:");
        TextField nr2 = new TextField();
        Label et3 = new Label("Rezultat:");
        TextField rezultat = new TextField();
        Button calculeaza = new Button();
        calculeaza.setText("Aduna");
       
        scena.setTitle("Primul meu calculator");
        FlowPane root = new FlowPane();
        root.getChildren().add(et1);
        root.getChildren().add(nr1);
        root.getChildren().add(et2);
        root.getChildren().add(nr2);
        root.getChildren().add(et3);
        root.getChildren().add(rezultat);
        root.getChildren().add(calculeaza);
        scena.setScene(new Scene(root, 400, 100));
        scena.show();
    }
}

Bibliography


No comments: