Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:04:36+00:00 2026-06-07T23:04:36+00:00

I can add SplitPane in a XYChart by clicking the Add Pane button, and

  • 0

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

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:04:37+00:00Added an answer on June 7, 2026 at 11:04 pm

    You can store a list of inner panes and remove them based on this list:

        final List<Pane> panes = new ArrayList<Pane>();
    
        button1.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
    
                BorderPane myborderpane = new BorderPane();
    
                //adding
                panes.add(myborderpane);
    
                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);
                }
            }
        });
    
        button2.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                if (panes.size() > 0) {
                    // removing from both list and splitPane childs
                    Pane toDelete = panes.remove(0);
                    splitPane.getItems().remove(toDelete);
                }
            }
        });
    

    Also you can remove panes directly from ScrollPane.getChildren() but it can involve tricky and unreliable code to determine which pane to remove.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can add several scrollviews with its background colours changed and it works fine.
I can add and remove the last line in my dynamic form and calculate
I can add a normal rightBarButton to my navigation without a problem but now
Can I add Custom SOAP header in WCF incoming/outgoing messages in basicHttpBinding, like we
How Can Add and Remove Rows based on the value of the numericupdown value??
I can add a float to my dictionary and that works well: [NSNumber numberWithFloat:[self.longitude
By clicking the Add Int Frame button I plot JInternalFrame on a tabbedPane, in
I can add an attribute to items in a RadioButtonList item like so: PaymentMethodDropDownList.Items[0].Attributes.Add(onclick,
How can add/remove/replace LIST in cookies using C#. //Declaring the List for image list
We can add any variable to class dynamically in php. What would be the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.