JavaFX Application Icon
Is it possible to change the application icon using JavaFX, or does it have to be done using Swing? 17 Answers 17
Is it possible to change the application icon using JavaFX, or does it have to be done using Swing? 17 Answers 17
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 years ago. Improve this question I have a very big program that is currently using SWT. The program can be run … Read more
How can I pass parameters to a secondary window in javafx? Is there a way to communicate with the corresponding controller? For example: The user chooses a customer from a TableView and a new window is opened, showing the customer’s info. Stage newStage = new Stage(); try { AnchorPane page = (AnchorPane) FXMLLoader.load(HectorGestion.class.getResource(fxmlResource)); Scene scene … Read more
I have been trying to display a marker on the map when I click on a Button of my JavaFX application. So what happens is when I click on that button, I write the position in a JSON file, this file will be loaded in the html file that contains the map. The problem is … Read more
I am trying to create a JavaFX program, and every time I try to run my code I am getting an exception – I’m not entirely sure what it means though… My code: package application; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; public class Main extends Application { @Override public … Read more
I am trying to create a JavaFX program, and every time I try to run my code I am getting an exception – I’m not entirely sure what it means though… My code: package application; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; public class Main extends Application { @Override public … Read more
Each FXML file is not necessarily a new Scene. A fxml is just a view file with its root element as any of the Layouts provided by Javafx. It may have multiple Layouts(as a part of the root layout) and controls depending on your requirement. To know more about fxml, you can view Java vs JavaFX Script vs FXML. … Read more
You can add an event filter to the scene with addEventFilter(). This will be called before the event is consumed by any child controls. Here’s what the code for the event filter looks like. scene.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { System.out.println(“mouse click detected! ” + mouseEvent.getSource()); } });
This worked for me: File >> Project Structure >> Modules >> Dependency >> + (on left-side of window) clicking the “+” sign will let you designate the directory where you have unpacked JavaFX’s “lib” folder. Scope is Compile (which is the default.) You can then edit this to call it JavaFX by double-clicking on the … Read more
Your MainController doesn’t have a zero-argument constructor. If the FXMLLoader encounters a fx:controller attribute on the root element, it attempts to create an instance of that controller by (effectively) calling the zero-argument constructor of the class specified in the attribute. To fix this (the simplest way), remove the fx:controller attribute from the FXML file, and … Read more