Tuesday, 12 June 2012

Advanced Calculator

And this is how my first meaningful JavaFX GUI looked like:


Then I made the stage transparent and added a close image:


I  got the idea from Zoran Pavlović blog. Thanks! :)

I'm already aware of several ways in which this application can be improved. Just in case you'd like to join me in learning JavaFX, I uploaded the code  here.

An excellent tutorial to get you started with TortoiseHG versioning control system  can be found here.

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


Saturday, 9 June 2012

JavaFX pe romaneste

Modelul interfetei  de programare JavaFX este cel al unei scene de teatru pe care actorii interpreteaza o piesa. Notiunile fundamentale sunt denumite in engleza Stage, Scene si Node. Pe romaneste, as spune

  • Scena

  • Decor

  • Actori


Primul pas in definirea unei interfete grafice in JavaFX este crearea unei scene. Scena este obiectul javafx.stage.Stage, aflat la dispozitia programatorului odata cu invocarea metodei start().

Un decor poate fi imaginat ca fiind una dintre ferestrele aplicatiei, in care actorii(subclase ale javafx.scene.Node, de exemplu text, imagini, forme geometrice, componente de tip UI) interactioneaza atat intre ei cat si cu spectatorii(utilizatorii aplicatiei).

Ar putea reprezenta o sursa de confuzie faptul ca "Scene" din engleza devine in romana "Decor", in timp ce "Scena" din romana este traducerea cuvantului "Stage". Cea mai buna modalitate de a intelege aceste concepte este programarea cu JavaFX a clasicei aplicatii Hello World.