Javafx 2 click and double click

Yes you can detect single, double even multiple clicks: myNode.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){ if(mouseEvent.getClickCount() == 2){ System.out.println(“Double clicked”); } } } }); MouseButton.PRIMARY is used to determine if the left (commonly) mouse button is triggered the event. Read the api of getClickCount() to conclude that there maybe multiple click … Read more

Label and Text differences in JavaFX

As Harry Blargle pointed out, “non-editable” means “not editable by the user.” So both Label and Text are non-editable. Label and Text have different CSS properties. Label inherits from Labeled, Control, and Region, which means it inherits a great many styleable properties which Text doesn’t have. A Label can have alignment, a graphic, a background, … Read more

JavaFX FileChooser and DirectoryChooser

A FileChooser is available as part of the JavaFX API. Example usage from javadoc: FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(“Open Resource File”); fileChooser.getExtensionFilters().addAll( new ExtensionFilter(“Text Files”, “*.txt”), new ExtensionFilter(“Image Files”, “*.png”, “*.jpg”, “*.gif”), new ExtensionFilter(“Audio Files”, “*.wav”, “*.mp3”, “*.aac”), new ExtensionFilter(“All Files”, “*.*”)); File selectedFile = fileChooser.showOpenDialog(mainStage); if (selectedFile != null) { mainStage.display(selectedFile); } A … Read more

JavaFX Location is not set error message [duplicate]

I had this problem and found this post. My issue was just a file name issue. FXMLLoader(getClass().getResource(“/com/companyname/reports/” + report.getClass().getCanonicalName().substring(18).replaceAll(“Controller”, “”) + “.fxml”)); Parent root = (Parent) loader.load(); I have an xml that this is all coming from and I have made sure that my class is the same as the fxml file less the word … Read more

close fxml window by code, javafx

give your close button an fx:id, if you haven’t yet: <Button fx:id=”closeButton” onAction=”#closeButtonAction”> In your controller class: @FXML private javafx.scene.control.Button closeButton; @FXML private void closeButtonAction(){ // get a handle to the stage Stage stage = (Stage) closeButton.getScene().getWindow(); // do what you have to do stage.close(); }

Maven Shade JavaFX runtime components are missing

UPDATE 10/2021 Since JavaFX 16 a warning is displayed when JavaFX doesn’t run on the module path, which is the case of an uber/fat jar: $ java -jar myFatJar-1.0-SNAPSHOT.jar Oct 02, 2021 1:45:21 PM com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported JavaFX configuration: classes were loaded from ‘unnamed module @14c24f4c’ Also, you get a warning from the shade … Read more

JavaFX 2.1 TableView refresh items

Since JavaFX 8u60 you can use(assuming tableView is an instance of TableView class): tableView.refresh(); From the documentation: Calling refresh() forces the TableView control to recreate and repopulate the cells necessary to populate the visual bounds of the control. In other words, this forces the TableView to update what it is showing to the user. This … Read more

All my JavaFX TextFields have lines in them

This is a known unresolved bug. The problem seems to be that it isn’t reproducible for the developers. In the comments of the bug report the use of a jvm parameter is suggested: -Dprism.disableRegionCaching=true However, if anyone is able to reproduce this very rare bug, my suggestion is to: modify the modena css file until … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)