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

Shadow on transparent stage gets darker

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • Win7, Java8b116

      For some reason when execution the test below the stage shadow gets darker each time when the mouse cursor is set. It looks like the shadow is repainted without clearing the existing shadow. In a real application the issue also occurs on other mouse moving/hover related events. The issue seems to be introduced between b99 and b106. The issue does not occur in b99.

      public class StageShadowTest extends Application
      {
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage stage)
        {
          System.err.println(System.getProperty("javafx.runtime.version"));
          //stage.initStyle(StageStyle.UNDECORATED);
          stage.initStyle(StageStyle.TRANSPARENT);

          final BorderPane root = new BorderPane();
          int shadowSize = 20;
          root.setStyle("-fx-background-color:#808080;-fx-background-radius:30;-fx-border-radius:30;-fx-border-width:14;-fx-border-color:blue;-fx-border-insets:" + shadowSize + ";-fx-background-insets:" + shadowSize + ";");
          root.setEffect(new DropShadow(BlurType.THREE_PASS_BOX, Color.BLACK, shadowSize, 0.25D, 0.0D, 0.0D));

          Pane content = new FlowPane(10, 10);
          root.setCenter(content);
          Button button = new Button("Button");
          content.getChildren().add(button);

          Scene scene = new Scene(root, 800, 600);
          stage.setScene(scene);
          scene.setFill(Color.TRANSPARENT);
          stage.show();

          root.addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>()
          {
            @Override
            public void handle(MouseEvent evt)
            {
              Cursor cursor = Cursor.DEFAULT;
              if (evt.getSceneX() < 34)
                cursor = Cursor.W_RESIZE;
              root.setCursor(cursor);
            }
          });

          final Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();
          Bounds bounds = button.localToScreen(button.getLayoutBounds());
          final int y1 = (int) (bounds.getMinY() + bounds.getHeight() / 2);
          final int y2 = (int) bounds.getMinY() + 60;
          final int x1 = (int) (bounds.getMinX() + bounds.getWidth() / 2);
          final int x2 = (int) bounds.getMinX() - 20;

          new Thread()
          {
            public void run()
            {
              for (int i = 0; i < 20; i++)
              {
                try
                {
                  sleep(250);
                }
                catch (InterruptedException e)
                {
                }
                final int j = i;
                Platform.runLater(new Runnable()
                {
                  @Override
                  public void run()
                  {
                    robot.mouseMove(j % 3 == 0 ? x1 : j % 3 == 1 ? x1 : x2, j % 3 == 0 ? y1 : y2);
                  }
                });
              }
            }
          }.start();
        }
      }

            flar Jim Graham
            wzberger Wolfgang Zitzelsberger
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: