Internal Frames in JavaFX

With JFXtras there is a Window control, where you can add content and handle the internal window behavior. First you will need to put in your classpath the jfxtras library. They have some instructions where you can get the library. If you are using maven, just need to add: <dependency> <groupId>org.jfxtras</groupId> <artifactId>jfxtras-labs</artifactId> <version>2.2-r5</version> </dependency> Or … Read more

How to pass object created in FXML Controller1 to Controller2 of inner FXML control

In FX 2.2 new API for controller-node was introduced: // create class which is both controller and node public class InnerFxmlControl extends HBox implements Initializable { @FXML public ComboBox cb; public InnerFxmlControl () { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(“fxml_example2.fxml”)); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } } with … Read more

Where can I download the JavaFX 2.2 source code? [closed]

JavaFX 2.2 is only partially open source. You can download the parts which are open from the zip link at: JavaFX 8 JavaFX 8 is completely open source today. Source for building JavaFX 8 (and the SceneBuilder design tool) is available at: Source code for later versions (including Java 8 updates), is in … Read more

JavaFX TableView Paginator

You have to use the Pagination control and implement a page factory. The factory is called for every page that should be displayed and you can use its parameter, the pageIndex, to provide a sublist of items to the TableView: TableView table = … private Node createPage(int pageIndex) { int fromIndex = pageIndex * rowsPerPage; … Read more

JavaFX open new window

If you just want a button to open up a new window, then something like this works: btnOpenNewWindow.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { Parent root; try { root = FXMLLoader.load(getClass().getClassLoader().getResource(“path/to/other/view.fxml”), resources); Stage stage = new Stage(); stage.setTitle(“My New Stage Title”); stage.setScene(new Scene(root, 450, 450));; // Hide this current window (if this is … Read more

Return result from javafx platform runlater

I’d recommend wrapping the code within a FutureTask object. FutureTask is a construct useful (among other things) for executing a portion of code on one thread (usually a worker, in your case the event queue) and safely retrieving it on another. FutureTask#get will block until FutureTask#run has been invoked, therefore your password prompt could look … Read more

JavaFX – Background Thread for SQL Query

I created a sample solution for using a Task (as suggested in Alexander Kirov’s comment) to access a database on a concurrently executing thread to the JavaFX application thread. The relevant parts of the sample solution are reproduced below: // fetches a collection of names from a database. class FetchNamesTask extends DBTask<ObservableList<String>> { @Override protected … Read more

JavaFX LineChart Hover Values

Use XYChart.Data.setNode(hoverPane) to display a custom node for each data point. Make the hoverNode a container like a StackPane. Add mouse event listeners so that you know when the mouse enters and leaves the node. On enter, place a Label for the value inside the hoverPane. On exit, remove the label from the hoverPane. There … Read more

JavaFX 2.1: Toolkit not initialized

Found a solution. If I just create a JFXPanel from Swing EDT before invoking JavaFX Platform.runLater it works. I don’t know how reliable this solution is, I might choose JFXPanel and JFrame if turns out to be unstable. public class BootJavaFX { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() … Read more

Javafx PropertyValueFactory not populating Tableview

Suggested solution (use a Lambda, not a PropertyValueFactory) Instead of: aColumn.setCellValueFactory(new PropertyValueFactory<Appointment,LocalDate>(“date”)); Write: aColumn.setCellValueFactory(cellData -> cellData.getValue().dateProperty()); For more information, see this answer: Java: setCellValuefactory; Lambda vs. PropertyValueFactory; advantages/disadvantages Solution using PropertyValueFactory The lambda solution outlined above is preferred, but if you wish to use PropertyValueFactory, this alternate solution provides information on that. How to Fix … Read more