fxml

JavaFX Progress Bar doesn't update

…衆ロ難τιáo~ 提交于 2019-12-11 08:07:09
问题 I've searched through all the other issues with this, but with no luck. I have been trying different things for over four hours and have gotten absolutely no progress (or errors, which is even more frustrating) so I figured I would finally ask here. I am working on a small survival game as a side project to teach myself more about Java UI elements. The player scavenges for food and such, and it is a race against starvation and thirst. The situation I have is such: The game opens into a

JavaFX 2.0 - create action handler for custom component in FXML

社会主义新天地 提交于 2019-12-11 06:39:33
问题 I want to add a custom action in my new component. How to do this? Example code: Component public class MyCustomComponent extends Region { public MyCustomComponent(){ super(); this.setOnMouseClicked(new EventHandler<MouseEvent>(){ @Override public void handle(MouseEvent event) { /* throw my custom event here and handle it in my FXML controller - but how? :-( */ } }); } } Controller public class MyController { @FXML protected void myCustomAction(ActionEvent event) { // do something } } FXML:

JavaFX Data Mangement [duplicate]

北慕城南 提交于 2019-12-11 06:23:47
问题 This question already has answers here : Passing Parameters JavaFX FXML (11 answers) Access fields from another Controller in JavaFX (2 answers) Closed 5 years ago . Scene 1 with its Scene1Controller! it has a text field (Customer Name) and a button! When I click the button in scene 1, a on-screen keyboard will appear without closing the scene! on-screen keyboard has it has its own controller! on-screen keyboard has a textfield and complete keyboard typed "stackoverflow" into the textfield of

Buttons in GridPane with prefWidth=“Infinity” break JavaFX

梦想的初衷 提交于 2019-12-11 05:08:07
问题 I am just starting with JavaFX so please excuse if this is a dumb mistake to make. I have a GridPane which I want to use to have two buttons next to eachother stretch over the whole width of the window. So I created a GridPane with one row and two collumns and added in my two buttons. Code for that: <GridPane id="GridPane" alignment="TOP_LEFT" disable="false" gridLinesVisible="false" hgap="5.0"> <children> <Button mnemonicParsing="false" styleClass="add-button" text="Save" GridPane

Java: file path when running from as JAR

 ̄綄美尐妖づ 提交于 2019-12-11 04:59:59
问题 I have a Java/JavaFX project where I use style sheets. Images from stylesheets will get loaded as follows: #pane { -fx-background-image:url('../packagename/image.jpg'); } It loads fine when I compile and run it from Eclipse or Scenebuilder. However, when running my jar file from the cmd ( java -jar project.jar ), it adds the file name to the path, changing it to: project.jar/packagename/image.jpg and obviously failing to load it. How do I get the correct path, or alternatively, omit the jar

Customizing TreeCells using cell factory

北慕城南 提交于 2019-12-11 04:47:59
问题 I am trying to represent a TreeCell like this: http://i.imgur.com/wv00CEi.png I have tried reading up on cell factories and I know I have to use this functionality. But how can I set the graphics to be like this for all the TreeCells? The image is stored as an HBox in an .fxml-file. Thank you so much :) P.S. Not necessarily looking for code in the answer here, more of a general explanation as to how to do this or why it doesn't work. This is the code I have tried. The fxml file is in the same

Cannot create FXML file in JavaFX project in Eclipse

谁说我不能喝 提交于 2019-12-11 04:43:46
问题 OS: Ubuntu 14.04. IDE: (Eclipse Mars.1 Release (4.5.1)) and Scene builder 2. I can't choose root element because as I understand it should be done. This window I see when creating a file. Maybe I incorrectly set the path to my Scene Builder executable. How to solving this problem? I did everything according to instructions. Update 1: Not yet solved the problem, I'll use the Idea IDE Update 2: Now i use Netbeans with JDK from ORACLE website. I chose the easiest way. 回答1: The problem is solved

Fxml Controller Inject Final Field

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:32:12
问题 For a fxml controller class that would map to an fxml control, such as: public MyController { @FXML private Button button; } Is it possible to declare the button field as final? If it was done, the java compiler (javac) would flag an error about that field not being initialized. It is understood that the button field will be eventually initialized using the @FXML injection. Albeit, javac does not fully understand this, or even how it would be done. Although the final qualifier may not be

How to resize Javafx undecorated stage?

非 Y 不嫁゛ 提交于 2019-12-11 03:42:21
问题 I am new to JavaFX technology, currently I am working on javafx application, in which there is undecorated stage,I am able to move it on screen using below code , but I am not able to resize this window from bottom right corner , can anyone suggest me the solution. public void loadPanel(final Stage stage) { myPane.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { xOffset = event.getSceneX(); yOffset = event.getSceneY(); } }); myPane

Combo box menu item font change in fxml

删除回忆录丶 提交于 2019-12-11 03:16:38
问题 I need to change the font and remove the shadow for the combo box items. I've made an attempt with the code below but it was unsuccessful: .combo-box .popup-menu, .combo-box .menu-item, .combo-box .popup-menu .menu-item-radio { -fx-shadow-highlight-color: transparent; -fx-font-family: "Arial"; -fx-font-size: 14px; } 回答1: For JavaFX2 you can create a CellFactory to set it: import javafx.application.Application; import javafx.collections.FXCollections; import javafx.scene.Scene; import javafx