Javafx 8 : Populating a TableView in initialize method

You replace your TableView in your initialize method. table =new TableView<Employee>(employees); You assign the data to the new TableView and leave the one created from the fxml empty. Instead use the one injected by the FXMLLoader: @Override public void initialize(URL location, ResourceBundle resources){ super.initialize(); dao = (DAO<Employee>) dFact.getEmployeeDAO(); try { employees = dao.findAll(); // set … Read more

Dynamic Bar chart in Java FX

Here is mcve demonstrating a mechanism to couple changing data to a BarChart. There are other ways to achieve this “binding”, but I tried to keep is simple. The bubble sort algorithm is not relevant to the question, not the answer , so it is better left out. An mcve needs to demonstrate the question … Read more

Localdate.format, format is not applied

Don’t format your date for insertion into your SQL database. Assuming that your database column has datatype date and you are using at least Java 8 and at least JDBC 4.2, just pass the LocalDate to your PreparedStatement as it is: PreparedStatement insertStmt = myConnection.prepareStatement( “insert into my_table(purchase_date) values (?)”); insertStmt.setObject(1, purchaseDate); Your JDBC driver … Read more

Customize ListView in JavaFX with FXML

I understand your question. There are mainly two ways to set items in a Listview: 1. Create the ObservableList and set the items of the ListView with the ObservableList (listView.setItems(observableList)). 2. Use the setCellFactory() method of the ListView class. You would prefer to use the setCellFactory() method, because this approach simplies the process as well … 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

Cant create new FXML File in Eclipse

It looks like e(fx)clipse hasn’t been updated for 2022-12, which removed some DataBinding APIs. You can open an issue at https://github.com/eclipse-efx/efxclipse-eclipse/issues, but if you can work up a pull request to fix it, that’ll probably move things along far more quickly.

FXMLLoader getController returns NULL?

Change this @FXML public void editPerson() { try { FXMLLoader loader = new FXMLLoader(getClass().getResource( “PersonEditor.fxml”)); PersonEditorCtrl ctrl = loader.getController(); ctrl.init(table.getSelectionModel().getSelectedItem()); Parent root = (Parent) loader.load(); Scene newScene = new Scene(root); Stage newStage = new Stage(); newStage.setScene(newScene); newStage.show(); } catch (Exception e) { e.printStackTrace(); } } To that: @FXML public void editPerson() { try { FXMLLoader … Read more

JavaFX Nested Controllers (FXML )

Thanks to Daniel (from OTN) I found the error in my code, the names of my controller variables were wrong. They should be <fx:id>Controller. In other words it should be: MainController.java public class MainController extends Controller { @FXML private Window dialog1; @FXML private DialogController dialog1Controller; @FXML private Window dialog2; @FXML private DialogController dialog2Controller; But studying … Read more

Where has the JavaFX scene builder gone?

With JDK8u40, according to this: Starting with Oracle Java SE 8u40, Oracle does not provide a separate set of accompanying JavaFX Scene Builder binaries. If you would like to contribute changes, ideas or just let us know what you have done with the code, please consult the OpenJDK Community contribution guidelines and join the openjfx-dev … Read more