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

Transparent stage bottom is shaking on changing stage Y postion and height

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 20.04.6 LTS
      JavaFX 20
      OpenJDK 22.0.1+8-16

      A DESCRIPTION OF THE PROBLEM :
      Run the provided code. You will see that on changing transparent stage Y position and height the bottom side is shaking, see <link> The same problem with the right side while changing X position and width. Besides, you will see the same problem if you use undecorated stage.

      It is not possible to test the provided code in javafx 21-24 because of the JDK-8344372 .

      Because of this bug it is not possible to use a custom stage in JavaFX as the bug doesn't let to implement the window resizing using top/left border. Similar to JDK-8344372, this bug prevents performing the most basic operations with Stage.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code. Click on the stage and move mouse up and bottom.


      ---------- BEGIN SOURCE ----------
      public class NewMain extends Application {

          public static void main(String args[]){
              launch(args);
          }

          private Stage stage;

          private double initialY;

          private double initialHeight;

          private double initialMouseY;

          @Override
          public void start(Stage stage) throws Exception {
              this.stage = stage;
              var root = new VBox();
              root.setStyle("-fx-background-color: yellow");
              root.setOnMousePressed(e -> onMousePressed(e));
              root.setOnMouseDragged(e -> onMouseDragged(e));
              var scene = new Scene(root, 600, 400);
              stage.initStyle(StageStyle.TRANSPARENT);
              stage.setScene(scene);
              stage.show();
          }

          private void onMousePressed(MouseEvent e) {
              this.initialY = stage.getY();
              this.initialHeight = stage.getHeight();
              this.initialMouseY = e.getScreenY();
          }

          private void onMouseDragged(MouseEvent e) {
              var d = this.initialMouseY - e.getScreenY();
              stage.setHeight(this.initialHeight + d);
              stage.setY(this.initialY - d);
          }
      }
      ---------- END SOURCE ----------

        1. mac-behavior.mov
          685 kB
          Ambarish Rapte
        2. screenshot.gif
          444 kB
          Anupam Dev
        3. Test.java
          1 kB
          Anupam Dev

            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: