fxml

Is It Possible To Import Classes into FXML <fx:script> block (JavaFX-2)

百般思念 提交于 2019-12-12 05:16:21
问题 I'm trying out JavaFX-2 and one of the features is said to be that we can create event handler functions using Javascript in our FXML file. One thing that bugged me is I can't access the System class right away. It needs to be fully referenced, like "java.lang.System". That becomes ugly when we need a simple output on the console, I mean come on, "System.out.println" is ugly enough to get something printed. And, even though my FXML has all the <?import java.lang.*?> statements, apparently it

JavaFX change Pane color from a different class

妖精的绣舞 提交于 2019-12-12 04:57:12
问题 I have a question. I want to change the color of a pane from another controller class. I am using this code: FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Menu.fxml")); try { Parent loaded = (Parent) loader.load(); } catch (IOException e) { e.printStackTrace(); } MenuController controller = (MenuController) loader.getController(); Platform.runLater(new Runnable() { @Override public void run() { Pane pane = controller.getRedPane(); pane.setBackground(new Background(new

Error in Loading FXML file into Anchor Pane in JavaFX

ぃ、小莉子 提交于 2019-12-12 04:39:56
问题 My currently developing program has one menu and one Anchor Pane to show content according to the selected menu item.In my program,I want to load my fxml file into content anchor pane which is again inside the main fxml file when user clicks menu item form menu bar.I have built anchor pane in main.fxml. <AnchorPane id="main_panel" layoutY="28.0" prefHeight="700.0" prefWidth="670.0" /> I have built that method in controller class for Main.fxml.DashBoard.fxml and controller class for DashBoard

Error when doing the JavaFX FXML tutorial from Oracle

时间秒杀一切 提交于 2019-12-12 04:03:35
问题 Good Day, I a working my way through the official JavaFX FXML tutorial (See source code here). However when I compile it using the Netbeans IDE I get the following error: Can anyone help me with this I'm running JDK 1.7 and JavaFX 2.0 init: Deleting: C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties deps-jar: Updating property file: C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties compile: Detected JavaFX Ant

How can I fix a NullPointerException when interacting with FXML elements in the start method?

℡╲_俬逩灬. 提交于 2019-12-12 03:46:29
问题 I'm writing some code where I interact (Change text) with FXML elements from the start method. However, I find that when I call the method from my controller class I get a NullPointerException. I've found that the issue has something to do with threads, but I have been able to get anything to work. I have included some sample code that generates the same problem. Main class: public class Main extends Application { Controller C = new Controller(); @Override public void start(Stage stage)

Text.setText() not updating text, throws NullPointerException

好久不见. 提交于 2019-12-12 03:38:34
问题 I'm having a bit of trouble with the Text.setText() method. It is supposed to set the String name as it's value. The FXML code has the text: <Text fx:id="airlineName" strokeType="OUTSIDE" strokeWidth="0.0" text="Airline Name Goes Here" GridPane.rowIndex="1"> <font> <Font size="17.0" /> </font> </Text> Here is a fragment of the java code: @FXML Text airlineName; private void loadNewWindow(String resource, Button button) throws IOException { Stage stage = (Stage) button.getScene().getWindow();

Programmatically resize TableColumns in JavaFX

为君一笑 提交于 2019-12-12 03:37:24
问题 I am trying to make a TableView to programmatically resize its columns at startup in order to fit its content, to achieve this I found a method which works great when bound to a listener (for example #onKeyPressed ). But when i try to bind it to the showingProperty() of the primaryStage in order to call it without any user action it throws a NullPointerException on columnToFitMethod.invoke(tableView.getSkin(), column, -1) . In a previous post I exposed a similar problem, the difference was

To use or not to use java FXML builders

允我心安 提交于 2019-12-12 03:16:53
问题 We have started to use the java FX with FXML for a desktop application. We need to load some combos with values from a local cache and we created a builder that instantiate the combo, fill it with values from cache and return it. We expect to have around 20 builders. I know most of java FX builders are deprecated because of this http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-March/006725.html According to a FXML tutorial if the FXMLLoader cannot create an object of a class, it looks

FXML StackPane doesn't align children correctly

亡梦爱人 提交于 2019-12-12 03:06:15
问题 I want a Rectangle and a Label to align in the StackPane, however my code doesn't achieve the desired result: FXML: <fx:root type="HBox" xmlns:fx="http://javafx.com/fxml"> <StackPane fx:id="pane"> <children> <Rectangle fx:id="bubble" fill="#ffffff"></Rectangle> <Label fx:id="message" style="-fx-border-color:black; -fx-border-width: 1; -fx-border-style: solid;"></Label> </children> </StackPane> </fx:root> Controller: public class MessageBubble extends HBox implements Initializable { @FXML

NullPointerException loading fxml file from javafx applet

你说的曾经没有我的故事 提交于 2019-12-12 02:56:24
问题 I'm trying to create javafx applet, using IntelliJ Idea. After building I get three files: .jar, .jnlp and .html. If I launch jar all works fine, but if I try to run app using jnlp or html it throws exception: java.lang.NullPointerException: Location is required. at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at javafx.fxml.FXMLLoader