## NCSSS 2018 JavaFX Workshop

All sample code in the session is present in the directory sampleCode linked at the left.

## Prepare your Lappy!

You will want to do one of these. You will need to have a developer kit for Java 9 or later (10) on your lappy. Instructions for the NetBeans and Eclipse IDEs are also present. I will use the good old command line with vim on my Mac.

• This site will show you how to use NetBeans for programming in JavaFX.
• This site will show you how to prepare Eclipse for Programming in JavaFX.
• See "update path" here to get java, javac and jshell to work in a PowerShell or cmd window.
• BlueJ fans, the link here will tell you about using JavaFX in BlueJ.

Here is a template for FX programs. You should try to compile and run this in advance. You can download it in the navigation area to the left.

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Template extends Application
{
public Template()
{
}
@Override
public void init()
{
}
@Override
public void start(Stage primary)
{
primary.setTitle("Template");
primary.show();
}
@Override
public void stop()
{
}
//Main is actually optional.
public static void main(String[] args)
{
launch(args);
}
}


Running this app results in this window.

Purpose and Audience This workshop is aimed at people who have a good working knowledge of programming basics, and Java fundamentals such as classes, inheritance, abstract classes, interfaces, and generics (that <T> stuff). It is very helpful if you are comfortable reading and applying the JavaAPI guide.

No prior knowledge of GUI programming is assumed. You are encouraged to follow along, experiment, raise questions and dicuss ideas. To some extent, this workshop will be driven by audience interest. This is a "dirty hands" experience. I hope you leave this with some sample code and an sense of adventure about exploring the world of GUI programming.

You will see that your students gain a whole new feeling of power over their computers the first time they make a GUI run and when they build their first actual application.

Also, we will spend a little time on the new jshell REPL (read-evaluate-print loop) and use it to demonstrate some Java8 concepts we will find useful.

Learning Resources In case you want to cheat and peek over the transom, here are some nice materials germane to this workshop.

• Oracle's JShell Introduction is a fairly complete guide.
• Sharan, Kishori, Learn JavaFX8, APress, 2015. This is a pretty complete guide to JavaFX, including such things as SceneBuilder and FXML.
• Chinn, Gao, Weaver, and Iverson Pro JavaFX9: A Definitive Guide to Building Desktop, Mobile, and Embedded Java Clients, 2018. This is a more advanced guide to JavaFX.
• Bloch, J. Effective Java, 3rd Edition, 2017. This very useful book dicusses a lot of new Java features, including lambdas and the new Streams API. It belongs on any serious Java programmer's bookshelf.
• Bucky shows you some basic ideas in JavaFX. It's unorthodox but it is well explained in simple terms. There is a whole series of tutorials.
• Thistutorial covers the basics of using SceneBuilder, which can be used to create GUIs. Scence builder uses FXML to create a GUI.
• Morrison, John, Introducing Java is a chapter of the textbook we use in teaching in our Java track. It assumes a working knowledge of the basics of a programming language. It introduces these ideas using jshell.
• Morrison, John, Interfaces, Inheritance and Java GUIs is a chapter of the textbook we use in introducting FX in our Java track. It is our introduction to inheritance that incorporates GUIs.

Next: application.php