Skip to content

Instantly share code, notes, and snippets.

@ahn94
ahn94 / FXML 2 Ways to Load Controller Class
Created January 24, 2016 01:52
FXML How to get controller class
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.
@ahn94
ahn94 / 0_reuse_code.js
Created January 24, 2016 01:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ahn94
ahn94 / ObservableDBwithTableView
Last active August 29, 2015 14:24
Good example:observalbe listtableviewsimle database
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;
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;
@ahn94
ahn94 / ComboExample.java
Created July 12, 2015 02:38
ComboBox is useful
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 {
@ahn94
ahn94 / ChoiceBoxListen.java
Created July 12, 2015 02:16
Listens for change in selection of choiebox selection
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 {
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 {
@ahn94
ahn94 / ValidateInt.java
Created July 12, 2015 01:06
Extract and validate textview input
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;
}
}
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();
/*
* 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;