JavaFX - A Brief History and First Project

es6

JavaFX is modern open source GUI toolkit first released in the year 2008 for developing rich internet applications(RIAs) in Java.

JavaFX was originally developed by Chris Oliver at SeeBeyond and was called F3(Form Follows Function).

F3 then was a scripting language that allowed you develop Graphical User Interfaces in a declarative syntax.

It also provided:

  1. Static Typing.
  2. Type Inference.
  3. Data Binding.
  4. Animation and 2D graphics etc.

Sun Microsystems acquired SeeBeyond and renamed F3 to JavaFX in 2007.

Oracle then acquired Sun MicroSystems in 2010 and opensourced JavaFX in 2013.

The first version of JavaFX was released in 2008.

Year Version Description
2008 JavaFX 1.0 Initial release of JavaFX. Was tne a declarative language called JavaFX script.
2009 JavaFX 1.1 Support for mobile was introduced.
2009 JavaFX 1.2
2010 JavaFX 1.3,1.3.1
2011 JavaFX 2.0 Started using Java Programming Language to write JavaFX code. JavaFX script was dropped.
2012 JavaFX 2.1 Support for Mac OS for desktop was introduced.
2012 JavaFX 2.2
2014 JavaFX 8.0 Version jumped from 2.2 to 8.0 so that JavaFX versions can match Java SE versions.

Creating a JavaFX application

Creating a JavaFX application basically involves three steps.

  1. A JavaFX application has to inherit from the Application class. That class resides resides in the javafx.application package.
import javafx.application.Application;

public class Starter extends Application {

}

We've declared a package, an import statement and class declaration/

  1. Override the start() method. So far our app above cannot compile. This is because we've not overriden the start() method which is an abstract method defined in the Application class. Normally abstract methods have to overridden so that you provide their implementation. Unless of course you decide to make your own class abstract as well.
public abstract void start(Stage stage) throws java.lang.Exception

Here's how we override it:

@Override
    public void start(Stage primaryStage) throws Exception {

    }

The start() method is the entry point for all JavaFX applications. It is also called the JavaFX application launcher. As a a parameter we pass it Stage object. That Stage object is the primary stage of the application.

Your aplication can have more than one stage, however, the primary stage will always be created by the JavaFX runtime.

  1. Showing The Stage. In the real world, in a film setting, the stage is normally used to display a scene.

So is it in the JavaFX world. Our JavaFX scene can have visual components like text, shapes, images, controls,animations and effects.

And the user may interact with these.

The primary stage is the container scene.

The look and feel of your application will depend on the host environment. The JavaFX runtime will automatically handle the details on your behalf.

Remember JavaFX can not only run on desktop environment but also on web browser. Desktops for example require windows with title bars etc.

On the other with applets the primary stage gets embedded in the browser window.

The stage has to be shown for visuals to be displayed, that is if you jave any.

import javafx.application.Application;
import javafx.stage.Stage;

public class Starter extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Mr JavaFX");
        primaryStage.setHeight(500);
        primaryStage.setWidth(500);
        primaryStage.setResizable(false);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }
}

Result

JavaFX Starter

Best Regards.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:




Recommendations


What do You Think

Dear readers drop us your comments below. We are building a community of students and learners. Start by dropping us your suggestions below. What tutorials do you want us to do for example? Where can we improve? What are some awesome resources out there? Do you have any code you want to share with us?
By the way that example or snippet you have lying in your computer can really help beginner programmers. We can share it here with other students.

Previous Post Next Post