This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The two easiest ways of doing it for small applications are : | |
Do not specify the fx:controller in the fxml. Create a controller instance by passing data to it and then pass it to the FXMLLoader. | |
Specify the fx:controller in the fxml. Fetch the controller instance from the FXMLLoader and pass the data to the controller. | |
The following are the examples for both the above said types. Each of the example have 3 components : | |
FXML - The FXML file, which doesn't have the fx:controller declaration for the first type and has it for the second type. | |
Controller - Has a constructor for the first type. Has setter methods for the second type. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.control.cell.PropertyValueFactory; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.collections.ObservableList; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; | |
public class Main extends Application { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; | |
public class Main extends Application { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.application.Platform; | |
import javafx.geometry.Insets; | |
import javafx.scene.Scene; | |
import javafx.scene.control.*; | |
import javafx.scene.layout.*; | |
import javafx.stage.Stage; | |
public class Main extends Application { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean isInt(TextField input, String message){ | |
try { | |
int age = Integer.parseInt(input.getText()); | |
System.out.println("user is: " + age); | |
return true; | |
} catch (NumberFormatException e){ | |
System.out.println("Error: " + message + " is not a number"); | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GridPane grid = new GridPane(); | |
grid.setPadding(new Insets(10, 10, 10, 10)); | |
grid.setVgap(8); | |
grid.setHgap(10); | |
Label username = new Label("Username"); | |
GridPane.setConstraints(username, 0, 0); | |
//Name input | |
TextField nameInput = new TextField(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package fxzoomtest01; | |
import javafx.animation.KeyFrame; | |
import javafx.animation.KeyValue; | |
import javafx.animation.ScaleTransition; | |
import javafx.animation.Timeline; |
NewerOlder