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

Layout/painting issues when moving nodes multiple times in events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8
    • 7u15, 7u25, 7u40, 8
    • javafx
    • None

      The code below is supposed to show a pink anchor pane for 1 second after onShow, then switch to a green anchor pane. If you run it as it, it switches from pink to white. depending on hierarchy (like adding a scrollPane: Scene > BorderPane > center >ScrollPane >content> ap), clicking can cause it to turn green. If you comment the first select, it works fine. Calling requestLayout and layout() does not work. Nor does resizing the window or updating controls inside the pink/green anchor panes (if there are some inside). What does work is running the onShow code in the start() method or commenting out the first select. Original program also exibited this bug when opening files, which was all in a button onclick handler and selected several items before selecting the first.

      ```java
      package javafxbugtest;

      import javafx.application.*;
      import javafx.event.*;
      import javafx.scene.*;
      import javafx.scene.layout.*;
      import javafx.stage.*;

      public class JavaFXBugTest extends Application{
      private AnchorPane ap;
      private AnchorPane curr_child;
      public void start(final Stage stage){
      stage.setTitle("Strange Happenings");
      ap = new AnchorPane();
      ap.setPrefSize(1024,600);
      stage.setScene(new Scene(ap));
      stage.setOnShown(new EventHandler<WindowEvent>(){
      public void handle(WindowEvent we){
      final AnchorPane greenap = newAp("green");
      select(greenap); // comment this out and it works
      select(newAp("pink"));
      Thread t = new Thread(new Runnable(){
      public void run(){
      try{
      Thread.sleep(1000);
      }catch (InterruptedException ex){}
      Platform.runLater(new Runnable(){
      public void run(){select(greenap);}
      });
      }
      });
      t.start();
      }
      });
      stage.show();
      }
      public AnchorPane newAp(String color){
      AnchorPane ap = new AnchorPane();
      ap.setStyle("-fx-background-color: " + color + ";");
      ap.setMinSize(1000, 1000);
      return ap;
      }
      public void select(AnchorPane child){
      if (curr_child != null)
      ap.getChildren().remove(curr_child);
      ap.getChildren().add(child);
      curr_child = child;
      }
      public static void main(String[] args){
      launch(args);
      }
      }
      ```

            dgrieve David Grieve
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: