fxml

javafx change css at runtime

吃可爱长大的小学妹 提交于 2019-12-01 03:15:44
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 It should have the effect. Try this full demo code: public class CssThemeDemo extends Application { private String theme1Url = getClass().getResource("theme1.css").toExternalForm(); private String theme2Url = getClass().getResource("theme2.css").toExternalForm()

where is the: FXML Specification?

回眸只為那壹抹淺笑 提交于 2019-12-01 02:57:04
问题 I am looking for the Oracle FXML specification , reference manual or just user guide. I've come across quite a few books and blogs using the literal name, and nothing on Google, Stackoverflow, Wikipdeia or the JavaFX pages to link with such a document. The nearest I've come is a kind of help page: Introduction to FXML A similar stackoverflow question: FXML full reference? Has a few votes because the links are helpful so I'm not repeating them. The main reference cited is the JavaFX API

Javafx 2.0 : How to change the size of the radio-buttons circle with CSS?

﹥>﹥吖頭↗ 提交于 2019-12-01 02:25:47
问题 I try to change the radio-buttons size in my app build with FXML and CSS. I use the sceneBuilder. Thanks for your help ! Here is my actual CSS code for the radio-buttons : .radio-button .radio{ -fx-border-width : 1px ; -fx-border-color : #000 ; -fx-background-color : white ; -fx-background-image : null ; -fx-border-radius : 15px ; -fx-height : 15px ; /* Not working */ height : 5px ; /* Not working */ } .radio-button .radio:selected{ -fx-background-color : white ; -fx-background-image : null ;

How does FXMLLoader load the FXML's controller?

五迷三道 提交于 2019-12-01 01:55:00
问题 What happens when I call FXMLLoader#load() in JavaFX? Suppose the FXML controller extends a class that has a constructor. Will there be assurance that the constructor will be called? And if not, how will a new instance of the object be created? For example, in the code below, will the TextField() constructor be called? import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.Initializable; import javafx.scene.control.TextField; public class FXMLController extends TextField

how to locate fxml from another package?

 ̄綄美尐妖づ 提交于 2019-11-30 18:55:27
I have created a simple JavaFX application. It has two packages the main class is JFXTest2.java is in good package and the fxml and it's controller are in JFXTest2 package. now the problem is that i can not load the fxml in the main class. I tried loading the fxml like this: Parent root = FXMLLoader.load(getClass().getResource("jfxtest2.Screen.fxml")); and Parent root = FXMLLoader.load(getClass().getResource("jfxtest2/Screen.fxml")); and also Parent root = FXMLLoader.load(new URL("/jfxtest2/Screen.fxml")); but none of them worked.So how should i load the fxml from JFXTest2 package in the the

JavaFX & FXML: how do I set the default selected item in a ChoiceBox in FXML?

北战南征 提交于 2019-11-30 18:46:51
I have the following FXML: <ChoiceBox> <items> <FXCollections fx:factory="observableArrayList"> <String fx:value="2 minutes" /> <String fx:value="5 minutes" /> <String fx:value="15 minutes" /> </FXCollections> </items> </ChoiceBox> But in the GUI it just shows a ChoiceBox with a default of nothing. I would like the first element in the list to be the default, and for a choice of "null" or nothing to be prohibited. How do I accomplish this? I added the value attribute to the ChoiceBox tag, and that worked. <ChoiceBox value="2 minutes"> <items> <FXCollections fx:factory="observableArrayList">

How to populate TableView dynamically with FXML and JavaFX

▼魔方 西西 提交于 2019-11-30 16:56:38
How do I define my table in FXML and then use my JavaFX code to populate it dynamically at runtime? Define the TableView in the fxml file. Few things to note: the root should have a controller class associated with it. the TableView and TableColumn should have fx:id attributes specified. <BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="com.example.MyController"> <center> <ScrollPane disable="false" visible="true"> <content> <TableView fx:id="myTableView" prefHeight="-1.0" prefWidth="-1.0"> <columns> <TableColumn fx:id="idColumn" prefWidth="100.0" text="Id" /> </columns> </TableView

How can I make constant variables in Javafx for XML files

我们两清 提交于 2019-11-30 14:15:36
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? 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 the class you are using. James_D showed you the way of doing it with a custom class. Another way of doing it

How to implement language support for JavaFX in FXML documents?

梦想的初衷 提交于 2019-11-30 14:00:22
How can I have different languages for a view in a FXML document to support many countries? Use ResourceBundle s to store the locale-dependent text, and access the data in the bundle using "%resourceKey" . Specifically, create text files for each language you want to support and place them in the classpath. The Javadocs for ResourceBundle have the details on the naming scheme, but you should have a default bundle defined by BaseName.properties and bundles for other languages and variants defined by BaseName_xx.properties . For example (with the resources directory in the root of the classpath)

How to extend custom JavaFX components that use FXML

柔情痞子 提交于 2019-11-30 13:18:21
How do I properly extend a custom JavaFX component to add or modify its GUI components if it uses FXML for the view? As an example scenario, suppose I use the following approach of creating a custom JavaFX component: SpecializedButton.java (Controller) package test; import java.io.IOException; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.HBox; public class SpecializedButton extends HBox { @FXML private Button button; @FXML private Label label; public SpecializedButton() { FXMLLoader