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

[SpltPane] Cannot set divider position in multiple splitpanes at once under certain conditions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u40
    • None
    • javafx

      From Mike Richardsson:
      We noticed in our application that the problem is not fixed. We have more levels of nested split panes than the original example...

      Here is the original example modified to show this issue still requires some work. Notice if you press the Adjust button the dividers are being set on each occasion. The problem seems to occur when we add tables to each split pane (which our application does)

      package application;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Insets;
      import javafx.geometry.Orientation;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.SplitPane;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.AnchorPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.text.Font;
      import javafx.stage.Stage;


      public class JavaFXTest extends Application {
           
          @Override
          public void start(Stage primaryStage) {
               
              AnchorPane ap = new AnchorPane();
               
              VBox base = new VBox();
              Button b = new Button("Adjust");
              base.getChildren().add(b);

             SplitPane sp = new SplitPane();
             sp.setOrientation(Orientation.VERTICAL);
                         
             SplitPane sp2 = new SplitPane();
             
             sp2.setOrientation(Orientation.HORIZONTAL);
             
             SplitPane sp4 = new SplitPane();
             
             sp4.setOrientation(Orientation.VERTICAL);
             
             sp2.getItems().add(createTableBox());
             SplitPane sp3 = new SplitPane();
             sp3.setOrientation(Orientation.VERTICAL);
             sp4.getItems().addAll(createTableBox(), createTableBox());
             sp4.setDividerPositions(0.7);
             
             sp3.getItems().addAll(sp4, createTableBox());
             sp3.setDividerPositions(0.3);
              
             sp2.getItems().add(0, sp3);
             sp2.getItems().add(1, createTableBox());
             sp2.setDividerPositions(0.5);
              
             sp.getItems().add(0, sp2);
             sp.getItems().add(1, createTableBox());
             sp.setDividerPositions(0.5);
              
             base.getChildren().add(sp);
             ap.getChildren().add(base);
              
             ap.setPrefSize(1000, 600);
             sp.setPrefSize(1000, 600);
                
              ap.autosize();
              base.autosize();
              sp.autosize();
              
              AnchorPane.setTopAnchor(base, 0.0);
              AnchorPane.setBottomAnchor(base, 0.0);
              AnchorPane.setLeftAnchor(base, 0.0);
              AnchorPane.setRightAnchor(base, 0.0);
              

             b.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent event) {
                      
                      //-> this is when the stage should adjust all three SplitPanes at once
                       // but only does one at a time
                      sp.setDividerPositions(0.9);
                      sp2.setDividerPositions(0.1);
                      sp3.setDividerPositions(0.9);
                      sp4.setDividerPositions(0.1);
                       
                  }
              });
               
               
              Scene scene = new Scene(ap, 1000, 600);
              scene.setRoot(ap);

              primaryStage.setScene(scene);
              primaryStage.show();
          }

          private VBox createTableBox() {
           TableView table = new TableView();
                table.setEditable(true);

                TableColumn firstNameCol = new TableColumn("First Name");
                TableColumn lastNameCol = new TableColumn("Last Name");
                TableColumn emailCol = new TableColumn("Email");
                
                table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
                
                final VBox vbox = new VBox();
                
                vbox.setSpacing(5);
                vbox.setPadding(new Insets(10, 0, 0, 10));
                final Label label = new Label("Address Book");
                label.setFont(new Font("Arial", 20));
                vbox.getChildren().addAll(label, table);
                          
                return vbox;
          }
          
          public static void main(String[] args) {
              launch(args);
          }
        
        
      }

            msladecek Martin Sládeček
            msladecek Martin Sládeček
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: