Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    88
    Rep Power
    0

    Default Remove SplitPane in XYChart

    I can add SplitPane in a XYChart by clicking the "Add Pane" button, and it works fine.

    Now I would like to remove SplitPane by clicking the "Remove pane" button.

    Here is full code

    Java FX Code:
    public class SplitPaneFxTest extends Application {
    
        SplitPane splitPane = new SplitPane();
        double    percSplit = 0.50;
        int       idxSplit  = 0;
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            launch(SplitPaneFxTest.class, args);
        }
        
        @Override
        public void start(Stage primaryStage) {
            primaryStage.setTitle("SplitPane Test");
            
            Group root = new Group();
            Scene scene = new Scene(root, 800, 650, Color.WHITE);
            
            //CREATE THE SPLITPANE        
            splitPane.setPrefSize(scene.getWidth(), scene.getHeight());
            splitPane.setOrientation(Orientation.VERTICAL);        
           
            //ADD LAYOUTS AND ASSIGN CONTAINED CONTROLS
            BorderPane upperPane = new BorderPane();
            HBox hbox = new HBox();
            
            Button button1 = new Button("Add Pane");
            hbox.getChildren().addAll(button1);
            upperPane.setTop(hbox);
            
            Button button2 = new Button("Remove Pane");
            hbox.getChildren().addAll(button2);
            upperPane.setTop(hbox);
    
            BorderPane lowerPane = new BorderPane();
            
            splitPane.getItems().addAll(upperPane);
            splitPane.setDividerPosition(idxSplit, 0.70);
            idxSplit++;
           
            splitPane.getItems().addAll(lowerPane);        
            idxSplit++;
    
            root.getChildren().add(splitPane);
    
            primaryStage.setScene(scene);
            primaryStage.show();
            
            button1.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                
                BorderPane myborderpane = new BorderPane();            
                splitPane.getItems().addAll(myborderpane);
                    
                ObservableList<SplitPane.Divider> splitDiv =  splitPane.getDividers();
                
                System.out.println("splitDiv.size() "+splitDiv.size());
                            
                percSplit = 1/(double)(splitDiv.size()+1);
                for (int i = 0; i< splitDiv.size(); i++) {                
                    System.out.println("i "+i+" percSplit "+percSplit);
                    splitPane.setDividerPosition(i, percSplit);
                    percSplit += 1/(double)(splitDiv.size()+1);
                }
              }
            });
        }
    }
    Any help really appreciated.

    Susie

  2. #2
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Remove SplitPane in XYChart

    I think that you should add this code:

    Java FX Code:
    button2.setOnAction(new EventHandler<ActionEvent>() {
            @Override 
            public void handle(ActionEvent e) {
                // your code for removing SplitPane by clicking on "Remove pane" button.
            }
    });

  3. #3
    Join Date
    Mar 2011
    Location
    Parma Italy
    Posts
    88
    Rep Power
    0

    Default Re: Remove SplitPane in XYChart

    Thanks cselic,

    just found the answer to solve this problem

    Susie

Similar Threads

  1. Log scale for Y axis in XYChart
    By susieferrari in forum JavaFX
    Replies: 6
    Last Post: 08-02-2012, 12:18 PM
  2. Zoom on XYChart + draw freehand
    By susieferrari in forum JavaFX
    Replies: 5
    Last Post: 07-26-2012, 04:54 PM
  3. Add JsplitPanes in XYChart
    By susieferrari in forum JavaFX
    Replies: 4
    Last Post: 07-16-2012, 01:20 PM
  4. Draw text and lines on a XYChart
    By susieferrari in forum JavaFX
    Replies: 2
    Last Post: 04-11-2012, 05:31 PM
  5. menubar in splitpane
    By masa in forum AWT / Swing
    Replies: 1
    Last Post: 12-16-2008, 10:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •