JavaFX How to set scene background image

One of the approaches may be like this: 1) Create a CSS file with name “style.css” and define an id selector in it: #pane{ -fx-background-image: url(“background_image.jpg”); -fx-background-repeat: stretch; -fx-background-size: 900 506; -fx-background-position: center center; -fx-effect: dropshadow(three-pass-box, black, 30, 0.5, 0, 0); } 2) Set the id of the most top control (or any control) in … Read more

How do I remove the default border glow of a JavaFX button (when selected)?

To remove the focus ring display from any control from within code: control.setStyle(“-fx-focus-color: transparent;”); To remove the focus ring for all controls, apply a stylesheet: .root { -fx-focus-color: transparent; } To only remove the ring for all buttons, use: .button { -fx-focus-color: transparent; } I find the -fx-focus-color attribute setting more straight-forward than relying on … Read more

JavaFX periodic background task

You can use Timeline for that task: Timeline fiveSecondsWonder = new Timeline( new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println(“this is called every 5 seconds on UI thread”); } })); fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE); fiveSecondsWonder.play(); for the background processes (which don’t do anything to the UI) you can use old good java.util.Timer: new Timer().schedule( … Read more

How to get stage from controller during initialization?

You can get the instance of the controller from the FXMLLoader after initialization via getController(), but you need to instantiate an FXMLLoader instead of using the static methods then. I’d pass the stage after calling load() directly to the controller afterwards: FXMLLoader loader = new FXMLLoader(getClass().getResource(“MyGui.fxml”)); Parent root = (Parent)loader.load(); MyController controller = (MyController)loader.getController(); controller.setStageAndSetupListeners(stage); … Read more

Passing Parameters JavaFX FXML

Using MVC Most of this answer focuses on a direct call to pass a parameter from a calling class to the controller. If instead, you want to decouple the caller and controller and use a more general architecture involving a model class with settable and listenable properties to achieve inter-controller communication, see the following basic … Read more

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