Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088801

Initializing Control class affects the style of Region

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • tbd
    • 8u20, 8u45
    • javafx
    • Windows 8

      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();
          }
      }

            Unassigned Unassigned
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Imported: