Introduction to
JavaFX
programming

By: Nicholas Duchon
Date: August 19, 2014
Jul 22, 2018

Outline:

  1. Minimum program
  2. Structure of FX displays
  3. Using Cascading  Style Sheets
  4. Using Layouts
  5. JavaFX Script
  6. Using FXML
  7. Animations
  8. Getting Fancy
  9. Deploying

Documentation:

  1. Java SE 8 documentation
  2. API - SE
  3. API - JavaFX
  4. JavaFX 2 - Ensemble - samples
  5. SE 8 Conceptual Diagram
  6. JavaFX Notes (Duchon)

A. The minimum FX Program:

  1. Import Application and Stage
    1. main seems to be optional
  2. Application is an abstract class, so requires:
    1. public void start (Stage)
  3. Start the application -
    1. static launch (String [])
    2. called in main
    3. call only ONCE!
    4. blocks - returns when all windows are closed
    5. without this, code doesn't do anything
  4. stage.show ()
    1. without this, no window shows up
    2. no window means no easy way to end the program!
import javafx.application.Application;
import javafx.stage.Stage;

public class TestFX_ND_A extends Application {

  // start required by Application abstract class:
  // seems to be optional in most environments:
  public void start (Stage stage) {
    stage.show ();
  } // end start
 
  public static void main (String args []) {
    launch (args);
  } // end main
} // end class TestFX_ND_A

B. Structure of FX displays (JavaFX 8):

  1. Screen
    1. Window
      1. PopupWindow or Stage
        1. Scene (JavaFX 8)
          1. Node (form a TREE of Node's, cycles illegal)
            Parent (does layouts, has children: eg: getChildren().add (Node) (From List interface))
            Group (mostly related to resizing children)
            1. Shape (a kind of Node) - Subclasses:
              1. Arc
              2. Circle
              3. CubicCurve
              4. Ellipse
              5. Line
              6. Path
              7. Polygon
              8. Polyline
              9. QuadCurve
              10. Rectangle
              11. SVGPath
              12. Text
            2. TextArea, TextField and PasswordField
              (kinds of Node -> Parent -> Region -> Control -> TextInputControl)
            3. Control (a kind of Node -> Parent) - Subclasses:
              1. Accordion
              2. ButtonBar
              3. ChoiceBox
              4. ComboBoxBase
              5. HTMLEditor
              6. Labeled
                1. ButtonBase
                  1. Button
                  2. CheckBox
                  3. Hyperlink
                  4. MenuButton
                    1. SplitMenuButton
                  5. ToggleButton
                    1. RadioButton
                2. Cell
                  1. DateCell
                  2. IndexedCell
                    1. ListCell
                      1. CheckBoxListCell
                      2. ChoiceBoxListCell
                      3. ComboBoxListCell
                      4. TextFieldListCell
                    2. TableCell
                      1. CheckBoxTableCell
                      2. ChoiceBoxTableCell
                      3. ComboBoxTableCell
                      4. ProgressBarTableCell
                      5. TextFieldTableCell
                    3. TableRow
                    4. TreeCell
                      1. CheckBoxTreeCell
                      2. ChoiceBoxTreeCell
                      3. ComboBoxTreeCell
                      4. TextFieldTreeCell
                    5. TreeTableCell
                      1. CheckBoxTreeTableCell
                      2. ChoiceBoxTreeTableCell
                      3. ComboBoxTreeTableCell
                      4. ProgressBarTreeTableCell
                      5. TextFieldTreeTableCell
                    6. TreeTableRow
                3. Label
                4. TitledPane
              7. ListView
              8. MenuBar
              9. Pagination
              10. ProgressIndicator
              11. ScrollBar
              12. ScrollPane
              13. Separator
              14. Slider
              15. Spinner
              16. SplitPane
              17. TableView
              18. TabPane
              19. TextInputControl
                1. TextArea
                2. TextField
                  1. PasswordField
              20. ToolBar
              21. TreeTableView
              22. TreeView

C. Using Cascading Style Sheets

D. Using Layouts

E. Using JavaFX Script

F. Using FXML

G. Animations

H. Getting Fancy

I. Deploying