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

Shadow on transparent stage gets darker

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      Win7, Java8b116

      Description

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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: