-
Bug
-
Resolution: Fixed
-
P3
-
fx2.1
When a style class is applied to a node using NodeBuilder#styleClass(), instantiation of the node fails, because NodeBuilder calls getStyleClass().setAll() rather than addAll() to apply the custom style classes. The following example demonstrates the problem:
NodeBuilderTest.java:
package test;
import java.util.Arrays;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.LabelBuilder;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class NodeBuilderTest extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
VBox root = new VBox();
root.getChildren().add(LabelBuilder.create().text("Hello World").styleClass(Arrays.asList(new String[] {"redLabel"})).build());
Scene scene = new Scene(root, 640, 480);
scene.getStylesheets().add("test/node_builder_test.css");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch();
}
}
node_builder_test.css:
.redLabel {
-fx-text-fill: #ff0000;
}
NodeBuilderTest.java:
package test;
import java.util.Arrays;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.LabelBuilder;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class NodeBuilderTest extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
VBox root = new VBox();
root.getChildren().add(LabelBuilder.create().text("Hello World").styleClass(Arrays.asList(new String[] {"redLabel"})).build());
Scene scene = new Scene(root, 640, 480);
scene.getStylesheets().add("test/node_builder_test.css");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch();
}
}
node_builder_test.css:
.redLabel {
-fx-text-fill: #ff0000;
}
- relates to
-
JDK-8101528 Problems creating scene graph with Builders
-
- Closed
-