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 8658573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:48:03+00:00 2026-06-12T15:48:03+00:00

I am creating an app which adds Tables to a Form and arrages them

  • 0

I am creating an app which adds Tables to a Form and arrages them in a specific layout. I’m creating a new leaf in MultiSplitPane everytime a new table needs to be added to the form, and I’m adding the new table to the leaf. Everything works fine until I move a divider and then try to add new leaf with a table inside.

Does anyone know what’s causing this mess and how I can fix it?

Here’s a working SSCCE that you can copy:

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.GraphicsConfiguration;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import org.jdesktop.swingx.MultiSplitLayout;
import org.jdesktop.swingx.MultiSplitPane;

/**
 * @author Igor
*/
public class Example extends javax.swing.JFrame {

/**
 * Creates new form Example
 */
@Override
public void add(Component cmpnt, Object o) {
    super.add(cmpnt, o);
}

@Override
public void add(PopupMenu pm) {
    super.add(pm);
}

@Override
public boolean action(Event event, Object o) {
    return super.action(event, o);
}

public Example(GraphicsConfiguration gc) {
    super(gc);
}

@Override
public Component add(Component cmpnt, int i) {
    return super.add(cmpnt, i);
}

@Override
public Component add(Component cmpnt) {
    return super.add(cmpnt);
}
// Initialize a MultiSplitPane
MultiSplitPane multiSplitPane = new MultiSplitPane();
int boxCount = 0;
String left = " (LEAF name=left0 weight=1)";
String right = "(LEAF name=right0 weight=0)";
String layoutDef = "(ROW" + left + " " + right + ")";
MultiSplitLayout.Node modelRoot = MultiSplitLayout.parseModel(layoutDef);

public Example() {
    initComponents();

    multiSplitPane.getMultiSplitLayout().setModel(modelRoot);
    setLayout(new BorderLayout());
    add(new JScrollPane(multiSplitPane), BorderLayout.CENTER);
    add(new JButton("Go") {
        {
            addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Example.this.addNode();
                }
            });
        }
    }, BorderLayout.SOUTH);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();

}
//a function that adds a new Leaf to the multiSplitPane
private void addNode() {

    if (boxCount == 1) {
        left = " (LEAF name=left0 weight=0.5)";
        right = " (LEAF name=right0 weight=0.5)";
    } else if (boxCount == 2) {
        left = "(COLUMN weight=0.5 left0 left" + new Integer(boxCount - 1).toString() + ")";
    } else if (boxCount == 3) {
        right = "(COLUMN weight=0.5 right0 right" + new Integer(boxCount - 2).toString() + ")";
    } else if ((boxCount % 2 == 0) && (boxCount != 0)) {
        left = left.substring(0, left.length() - 1);
        left += " left" + new Integer(boxCount / 2).toString() + ")";
    } else if ((boxCount % 2 != 0)) {
        right = right.substring(0, right.length() - 1);
        right += " right" + new Integer(boxCount / 2).toString() + ")";
    }
    String layoutDef = "(ROW " + left + " " + right + ")";
    MultiSplitLayout.Node modelRoot = MultiSplitLayout.parseModel(layoutDef);
    multiSplitPane.getMultiSplitLayout().setModel(modelRoot);

    JTable t = new JTable(1, 1);
    t.getColumnModel().getColumn(0).setHeaderValue("Box Title" + boxCount);
    Dimension dimension = new Dimension(190, 190);
    t.setPreferredScrollableViewportSize(dimension);
    t.setRowHeight(800);

    if (boxCount == 0) {
        multiSplitPane.add(new JScrollPane(t), "left0");
    } else if (boxCount == 1) {
        multiSplitPane.add(new JScrollPane(t), "right0");
    } else if (boxCount == 2) {
        multiSplitPane.add(new JScrollPane(t), "left1");
    } else if (boxCount == 3) {
        multiSplitPane.add(new JScrollPane(t), "right1");
    } else if (boxCount % 2 == 0) {
        multiSplitPane.add(new JScrollPane(t), "left" + new Integer(boxCount / 2).toString());
    } else if (boxCount % 2 != 0) {
        multiSplitPane.add(new JScrollPane(t), "right" + new Integer(boxCount / 2).toString());
    }

    multiSplitPane.revalidate();
    boxCount++;
}// End of AddNode *****************

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );

    pack();
}// </editor-fold>

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Example.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Example.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Example.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Example.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Example().setVisible(true);
        }
    });
}
// Variables declaration - do not modify
// End of variables declaration
}

P.S. Increase window size (or maximize) when you run the app.

  • 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-12T15:48:04+00:00Added an answer on June 12, 2026 at 3:48 pm

    I think multiSplitPane.setFloatingDividers(false) fixed the issue.

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

Sidebar

Related Questions

I am creating an iPad app which is a form with mostly text boxes.
I'm creating a Django app in which I have a table which has 'items',
I'm creating an app which allows the user to manipulate a table structure by
I am creating an app in which i have a UITableView and the table
I'm creating an app in which I want to have a new set of
I'm creating a small app in which you can add or delete a table
Hi i'm creating an app which have shopping cart and payment done via paypal
I am creating an app which is a guide. I have a photograph showing
I am creating an app which will have a question in a UILabel and
I am creating an app which has around 15 different animations. Some animations are

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.