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

Win: Strange behavior resizing several stages at the same time

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:

      Windows 7 64bit, jdk 1.8.0-b132

      Description

      Calling setWidth() or setHeight() method for each stage I have created at the same time, some stages aren't resized as expected. Adding a change listener to relative properties (widthProperty or heightProperty) you can see the value is changed correctly, but the stage isn't resized. With several stages (15, 20 or more) this behavior is more frequent.
      I noticed this behavior using java 1.8.0-b132.

      Test code:

      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class Application extends javafx.application.Application {

      @Override
      public void start(final Stage primaryStage) {
      final ObservableList<Stage> stages = FXCollections
      .observableArrayList();

      // Number of stages to create
      int count = 20;
      int columns = 5;

      int curColumn = 1;
      for (int i = 0; i < count; i++) {
      if (i % columns == 0) {
      curColumn++;
      }
      final Stage stage = new Stage();
      stage.setTitle("Stage " + (i + 1));
      stage.widthProperty().addListener(new ChangeListener<Number>() {
      @Override
      public void changed(ObservableValue<? extends Number> obs,
      Number oldX, Number newX) {
      System.out.println(stage.getTitle() + " W changed from "
      + oldX + " to " + newX);
      }
      });

      Button btn = new Button("Resize");
      btn.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent arg0) {
      System.out.println("\nResizing");
      for (Stage stg : stages) {
      stg.setWidth(150.0);
      }
      }
      });
      stage.setScene(new Scene(new StackPane(btn)));
      stage.setWidth(200.0);
      stage.setHeight(60.0);
      stage.setX(50 + 200.0 * (i % columns));
      stage.setY(70 * curColumn);
      stage.show();
      stages.add(stage);
      }
      }

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

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            abernardijfx Alessio Bernardi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Imported: