javafx

JavaFX Button with multiple text lines

梦想与她 提交于 2019-12-30 09:58:14
问题 I need to create a toolbar in my screen that will have multiple buttons, and each button must have multiple lines of Text. For example: I looked over the internet and StackOverflow but I couldn't find anything showing how to do this in JavaFX. I'm using JavaFX 8. Someone could help me, please? Tks 回答1: Also you can use the wrapTextProperty . But you have to set toolbar height greater than expected button height. Button btn = new Button(); btn.wrapTextProperty().setValue(true); // or btn

JavaFX Input Validation Textfield

帅比萌擦擦* 提交于 2019-12-30 09:57:38
问题 I'm using JavaFX and Scene Builder and I have a form with textfields. Three of these textfields are parsed from strings to doubles. I want them to be school marks so they should only be allowed to be between 1.0 and 6.0. The user should not be allowed to write something like "2.34.4" but something like "5.5" or "2.9" would be ok. Validation for the parsed fields: public void validate(KeyEvent event) { String content = event.getCharacter(); if ("123456.".contains(content)) { // No numbers

JavaFX java.lang.IllegalStateException: Location is not set

[亡魂溺海] 提交于 2019-12-30 09:52:11
问题 Help! I'm stuck.. I try to run my main javafx app Here is my codes; @Override public void start(Stage primaryStage) throws Exception { try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/com/utmkl/fxml/SimulatorDisplay.fxml")); Parent content = (Parent)loader.load(); primaryStage.setResizable(false); primaryStage.initStyle(StageStyle.UTILITY); primaryStage.setScene(new Scene(content)); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } Below

How to get TableHeaderRow from TableView nowadays in JavaFX?

霸气de小男生 提交于 2019-12-30 09:29:27
问题 I saw examples on how to get table header in many places with code TableHeaderRow header = (TableHeaderRow) tableView.lookup("TableHeaderRow"); like here: How to prevent TableView from doing TableColumn re-order in javaFX 8? But this code returns null for me. How to reach TableHeaderRow then? 回答1: The TableHeaderRow is created by the Skin and the default Skin is not created until css is applied. You could call applyCss after adding the TableView to a Scene and access the TableHeaderRow after

How to get TableHeaderRow from TableView nowadays in JavaFX?

可紊 提交于 2019-12-30 09:29:20
问题 I saw examples on how to get table header in many places with code TableHeaderRow header = (TableHeaderRow) tableView.lookup("TableHeaderRow"); like here: How to prevent TableView from doing TableColumn re-order in javaFX 8? But this code returns null for me. How to reach TableHeaderRow then? 回答1: The TableHeaderRow is created by the Skin and the default Skin is not created until css is applied. You could call applyCss after adding the TableView to a Scene and access the TableHeaderRow after

javafx change css at runtime

若如初见. 提交于 2019-12-30 08:19:52
问题 Is it possible to change css for a JavaFX application while it is running? The effect I am looking for is changing skins or themes at the click of a button. The UI is in an FXML file if that makes any difference. I have tried Scene.getStylesheets() .add(getClass().getResource(skinFileName).toExternalForm()); which has no effect. thanks 回答1: It should have the effect. Try this full demo code: public class CssThemeDemo extends Application { private String theme1Url = getClass().getResource(

Rendering a POJO with JavaFX 2's Combo Box without overriding the toString() method

纵然是瞬间 提交于 2019-12-30 08:04:30
问题 I have a list of employees whose names I need to render on a combo box for the user to select. The following code renders the names on the dropdown list, but when I select a name, the combo's displayed text contains the full POJO's identity, a string like "src.org.entities.Employee@449ac7ce" cboEmployees.setCellFactory(new Callback<ListView<Employee>, ListCell<Employee>>() { @Override public ListCell<Employee> call(ListView<Employee> p) { return new ListCell<Employee>() { @Override protected

Rendering a POJO with JavaFX 2's Combo Box without overriding the toString() method

泪湿孤枕 提交于 2019-12-30 08:04:20
问题 I have a list of employees whose names I need to render on a combo box for the user to select. The following code renders the names on the dropdown list, but when I select a name, the combo's displayed text contains the full POJO's identity, a string like "src.org.entities.Employee@449ac7ce" cboEmployees.setCellFactory(new Callback<ListView<Employee>, ListCell<Employee>>() { @Override public ListCell<Employee> call(ListView<Employee> p) { return new ListCell<Employee>() { @Override protected

Calling clear() on ObservableList causes IndexOutOfBoundsException

你说的曾经没有我的故事 提交于 2019-12-30 07:18:06
问题 I have a ComboBox with an observablelist which is updated as the user types in characters or makes a selection. The issue I am having is caused when I select an item from the ComboBox and my listener event is called which then calls the clear() method from the ComboBox's ObservableList. FULL CODE public void suggestItem(ActionEvent ev){ String currentInput = foodSearch.getEditor().getText(); if(currentInput.length() > 4){ DatabaseCommunicator.openConnection(); // Returns a list no greater

JavaFX Single Instance Application

China☆狼群 提交于 2019-12-30 06:49:06
问题 Trying to make it so when the user "closes" the program clicking all the exit buttons so there is no more tray icon. I called Platform.setImplicitExit(false); so the program still runs in backround. I am trying to learn how to make it so when the user re-clicks the .exe files which runs the jar,instead of running a new program it re-shows that one that is running in background. Platform.setImplicitExit(false); 回答1: This is based upon the solution in the blog post: Java Single Instance