When Labeled.getClassCssMetaData() gets touched the first time a sideaffect appears.
A region without borders suddenly gets a new background with a bright grey color.
A workaround is, to touch Labeled.getClassCssMetaData() at the start of the application, so that Region keeps the same behaviour during the whole runtime, instead of switching on the first touch.
I assume, that the touch intializes the css engine.
See the sample program below.
package bug;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Labeled;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class TouchingLabeled extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
//Labeled.getClassCssMetaData(); //workaround
Region reg = new Region();
reg.onMouseClickedProperty().set(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Labeled.getClassCssMetaData();
}
});
System.out.println(System.getProperty("java.version"));
primaryStage.setScene(new Scene(reg, 300, 250, Color.BLUE));
primaryStage.show();
}
}
A region without borders suddenly gets a new background with a bright grey color.
A workaround is, to touch Labeled.getClassCssMetaData() at the start of the application, so that Region keeps the same behaviour during the whole runtime, instead of switching on the first touch.
I assume, that the touch intializes the css engine.
See the sample program below.
package bug;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Labeled;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class TouchingLabeled extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
//Labeled.getClassCssMetaData(); //workaround
Region reg = new Region();
reg.onMouseClickedProperty().set(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Labeled.getClassCssMetaData();
}
});
System.out.println(System.getProperty("java.version"));
primaryStage.setScene(new Scene(reg, 300, 250, Color.BLUE));
primaryStage.show();
}
}