-
Bug
-
Resolution: Fixed
-
P4
-
8u40
-
JavaFX 8_40 64bit, JDK 8_40 64bit, Windows 7 64bit, NetBeans 8.0.2
When loading a Spinner from an FXML, FXMLLoader ignored attribute styleClass.
Take the following FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox id="AnchorPane" style="-fx-spacing: 6;" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" fx:controller="test.TestFXMLController">
<Button fx:id="button" styleClass="my-button"/>
<ComboBox fx:id="combo" styleClass="my-combo"/>
<Spinner fx:id="spinner" styleClass="my-spinner"/>
</VBox>
And the following controller:
package test;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Spinner;
public class TestFXMLController implements Initializable {
@FXML
private Button button;
@FXML
private ComboBox combo;
@FXML
private Spinner spinner;
@Override
public void initialize(URL location, ResourceBundle resources) {
System.out.println("> Button");
button.getStyleClass().forEach(System.out::println);
System.out.println("> ComboBox");
combo.getStyleClass().forEach(System.out::println);
System.out.println("> Spinner");
spinner.getStyleClass().forEach(System.out::println);
}
}
And the following app class:
package test;
import java.io.IOException;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
final URL fxmlURL = getClass().getResource("test.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
final Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
primaryStage.setTitle("test");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
The output of this app is:
> Button
button
my-button
> ComboBox
combo-box-base
combo-box
my-combo
> Spinner
spinner
The Spinner object created by the FXMLLoader is missing the style "my-spinner"
Take the following FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox id="AnchorPane" style="-fx-spacing: 6;" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" fx:controller="test.TestFXMLController">
<Button fx:id="button" styleClass="my-button"/>
<ComboBox fx:id="combo" styleClass="my-combo"/>
<Spinner fx:id="spinner" styleClass="my-spinner"/>
</VBox>
And the following controller:
package test;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Spinner;
public class TestFXMLController implements Initializable {
@FXML
private Button button;
@FXML
private ComboBox combo;
@FXML
private Spinner spinner;
@Override
public void initialize(URL location, ResourceBundle resources) {
System.out.println("> Button");
button.getStyleClass().forEach(System.out::println);
System.out.println("> ComboBox");
combo.getStyleClass().forEach(System.out::println);
System.out.println("> Spinner");
spinner.getStyleClass().forEach(System.out::println);
}
}
And the following app class:
package test;
import java.io.IOException;
import java.net.URL;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
final URL fxmlURL = getClass().getResource("test.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL);
final Parent root = fxmlLoader.load();
Scene scene = new Scene(root);
primaryStage.setTitle("test");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
The output of this app is:
> Button
button
my-button
> ComboBox
combo-box-base
combo-box
my-combo
> Spinner
spinner
The Spinner object created by the FXMLLoader is missing the style "my-spinner"
- relates to
-
JDK-8134600 Can't pass ObservableList as argument using FXML
-
- Resolved
-