fxml

Getting started on Scala + JavaFX desktop application development

拥有回忆 提交于 2019-11-30 03:22:48
Is there some guide or walkthrough to building a Scala + JavaFX desktop application? I'm having hard time finding a good source and I am using IntelliJ IDEA as the IDE. Even the most simplistic desktop hello world samples would help a lot, because I have little clue where to start. Update: This is what I have now: import javafx.application.Application import javafx.scene.Scene import javafx.scene.layout.StackPane import javafx.stage.Stage import javafx.scene.control.Label class Test extends Application { override def start(primaryStage: Stage) { primaryStage.setTitle("Sup!") val root = new

Label and Text differences in JavaFX

天大地大妈咪最大 提交于 2019-11-30 02:39:06
What is the difference between javafx.scene.text.Text and javafx.scene.control.Label? The documentation says: Label is a non-editable text control. The Text class defines a node that displays a text. But the Label class has a method "setText" and "textProperty", therefore is editable. 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

JavaFX2 - very poor performance when adding custom made (fxml)panels to gridpane dynamically

被刻印的时光 ゝ 提交于 2019-11-30 02:21:46
Problem I want to add custom made panels, built via javafx scene builder, to a gridpane at runtime. My custom made panel exsits of buttons, labels and so on. My Attempt I tried to extend from pane... public class Celli extends Pane{ public Celli() throws IOException{ Parent root = FXMLLoader.load(getClass().getResource("Cell.fxml")); this.getChildren().add(root); } } ... and then use this panel in the adding method of the conroller @FXML private void textChange(KeyEvent event) { GridPane g = new GridPane(); for (int i=0 : i<100; i++){ g.getChildren().add(new Celli()); } } } It works, but it

How can I make constant variables in Javafx for XML files

前提是你 提交于 2019-11-29 20:57:31
问题 StackPane layoutY="70.0" prefHeight="479.0" . I want to make the values (70.0) and (479.0) static in a Java file so I can use them for other files. Is this possible? 回答1: If your constant is defined in a class: public class SomeClass { public static final double DEFAULT_HEIGHT = 479 ; // ... } then you can access it in FXML as follows: <StackPane> <prefHeight> <SomeClass fx:constant="DEFAULT_HEIGHT" /> </prefHeight> </StackPane> Make sure you have the appropriate import in the fxml file for

To Hide JavaFx fxml or JavaFx swing application to System Tray

て烟熏妆下的殇ゞ 提交于 2019-11-29 20:21:04
I want to develop a client app for website . I want the app to reside in system tray when minimised. I dont know how to accomplish this task . Is their any example for this type of operation. alscu The key here is to set the implicit exit to false Platform.setImplicitExit(false); Also is important to show and hide the stage in a new thread. Platform.runLater(new Runnable() { @Override public void run() { stage.show(); } }); Platform.runLater(new Runnable() { @Override public void run() { stage.hide(); } }); Next, the whole code: import java.awt.AWTException; import java.awt.MenuItem; import

JavaFX custom control (TextField) not working

混江龙づ霸主 提交于 2019-11-29 18:28:30
问题 I am trying to make a custom control with JavaFX and SceneBuilder 1.1. I have this code: FXML <?import libreria.javaFX.componentes.componenteTextField.*?> <AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml"> <children> <CustomComponent fx:id="pastaTxt" layoutX="69.0" layoutY="87.0" prefWidth="200.0" /> </children> </AnchorPane> CustomComponent.java package

How to call functions on the stage in JavaFX's controller file

女生的网名这么多〃 提交于 2019-11-29 18:27:24
问题 I am using javafx along with fxml , so I use the controller for the real coding . I need to do a few operations on the stage, such as getting its x- or y-axis position. I have tried stage.getX() & stage.getY , but they don't work(the stage name is high-lited as the error). How do I use such functions in my controller? I tried doing this in my main file: public int locationX = stage.getX(); and public double locationX = stage.getX(); But it doesn't work, instead makes the whole program one big

JavaFX - How to get FXML Controller? [duplicate]

…衆ロ難τιáo~ 提交于 2019-11-29 18:22:13
问题 This question already has an answer here: Accessing FXML controller class 4 answers I have the following code: Parent parent = FXMLLoader.load(Main.class.getResource("JanelaPrincipal.fxml")); in the fxml file there is a reference to the controller class. How can I get the controller object? fxml: <AnchorPane id="AnchorPane" fx:id="root" prefHeight="768.0" prefWidth="1024.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="br.meuspila.javafx

How to Update a TreeView in JavaFX with data from users

半世苍凉 提交于 2019-11-29 18:04:24
I am begging with JavaFx, and I realized that I need some help to update a TreeView with some TreeItems in runtime, and it should be updated in the main window. Here, you can see a screenshot of the two windows: The bigger is the main window and it calls (by clicking in File >> New Project), new smaller. In the smaller window, I could get the String that is typed and than the enter button is clicked. The trouble is: How can I show the new items created by the "new project window" (the smaller window in the pic) in the TreeView in the main window(the bigger)? The treeview is in the left side of

How to handle ListView item clicked action?

和自甴很熟 提交于 2019-11-29 16:25:02
问题 I have my JavaFX 2.0 application, where i need to make some action, after user clicked an item in ListView element. To construct user GUI i'm using FXML, in which i have something like this: <children> <ListView fx:id="listView" GridPane.columnIndex="0" GridPane.rowIndex="1" labelFor="$pane" onPropertyChange="#handleListViewAction"/> </children> And here is what i have in a Controller for this event: @FXML protected void handleListViewAction(ActionEvent event) { System.out.println("OK"); }