Saturday, February 28, 2015

JAVAFX

JAVAFX

FEBRUARY 2015. And so the past has finally reached the future to become the present.

Starting next month, this web page will write one programming blog in Knight in Programming once a week. I will also write one mathematics blog in Knight in Math web page once a week.

Since some employers also look for programmers who also know the software in the Microsoft Office suite like Word, Excel, and Access, I will also include them in the Knight in Programming blog. I will also include other programming aspects, not just the programming language itself.

For the Knight in Math blog, I will discuss all math subjects from Arithmetic to doctorate level Mathematics, essentially all of Mathematics.

JavaFX is the new paradigm for GUI programming in Java. First, there was AWT which was too much platform dependent. So the Swing package replaced AWT to make it less platform dependent. Now, since website technology have advanced, JavaFX was designed to match the advancement in website technology.

Here is a sample JavaFX application.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.*;
import javafx.scene.layout.*;

/**
 * Program Description.
 *
 * @author (John Sindayen)
 * @version (February 28, 2015)
 */
public class JavaFXGUI extends Application {
    @Override
    public void start(Stage primaryStage) {
        //Create components.
        primaryStage.setTitle("JavaFX GUI Application");
        FlowPane pane = new FlowPane();
        Scene scene = new Scene(pane, 300, 300);
        Label label = new Label("READ ME");
        TextField textField = new TextField("TYPE ME");
        Button button = new Button("CLICK ME");
     
        //Add components.
        pane.getChildren().addAll(label, textField, button);
        primaryStage.setScene(scene);
     
        //Show components.
        primaryStage.show();
    }
}

The GUI pictured here is a Swing GUI that can be coded into JavaFX.



The first picture is the main data entry form. The second picture is an error message that outputs when a data is not valid.

CYK:
What AWT package class do you use in Java to make a window?
What is the programming term for a sequence of characters?
What is the name of the character '\n'?

Java is fun!

John Sindayen

1 comment: