How do I pick up the Enter Key being pressed in JavaFX2?

I’m assuming you want this to happen when the user presses enter only while the TextField has focus. You’ll want use KeyEvent out of javafx.scene.input package and do something like this: field.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode().equals(KeyCode.ENTER)) { doSomething(); } } }); Using lambda: field.setOnKeyPressed( event -> { if( event.getCode() … Read more

How to switch scenes in JavaFX

I wrote this controller to keep track of the different scenegraphes. public class ScreenController { private HashMap<String, Pane> screenMap = new HashMap<>(); private Scene main; public ScreenController(Scene main) { this.main = main; } protected void addScreen(String name, Pane pane){ screenMap.put(name, pane); } protected void removeScreen(String name){ screenMap.remove(name); } protected void activate(String name){ main.setRoot( screenMap.get(name) ); … Read more

Differences between ComboBox and ChoiceBox in JavaFX

ComboBox supports a cellFactory which allows essentially an arbitrary UI for displaying the item in each cell. ChoiceBox does not have this functionality and will only display text in each cell (which you can configure using a converter). See http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/combo-box.htm#BABJCCIB listing 16.5 for an example of a custom cell factory in a combo box.

How to emit and handle custom events?

In general: Create a desired EventType. Create the corresponding Event. Call Node.fireEvent(). Add Handlers and/or Filters for EventTypes of interest. Some explanations: If you want to create an event cascade, start with an “All” or “Any” type, that will be the root of all of the EventTypes: EventType<MyEvent> OPTIONS_ALL = new EventType<>(“OPTIONS_ALL”); This makes possible … Read more

Kotlin. Basic JavaFX application

The code samples you provided are not equivalent: an object declaration in Kotlin is a singleton, so it only has one instance constructed by calling the private constructor when the class is initialized. JavaFX is trying to call the constructor of the class reflectively but fails because the constructor is private as it should be. … Read more

Include ControlsFX in Scene Builder?

Yes you can. But unfortunately all ControlsFX controls are not supported by scene builder. An issue titled, “All controls should be supported by SceneBuilder” is currently opened with the ControlsFX team. Update Since SceneBuilder 8.2.0 you can directly search for an artifact from SceneBuilder and include them using the brand new Library Manager \o/ To … Read more

Styling default JavaFX Dialogs

You can style your dialogs with your own css file, but for that you need to take into consideration that the dialog is in fact a new stage, with a new scene, and the root node is a DialogPane instance. So once you create some dialog instance: @Override public void start(Stage primaryStage) { Alert alert … Read more

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