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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:55:51+00:00 2026-05-15T19:55:51+00:00

I have an interface that has multiple small JTables stacked on top of each

  • 0

I have an interface that has multiple small JTables stacked on top of each other. I would like their column sizes, sorting, filtering, etc to stay in sync. Is there a straightforward way to do this?

For the column widths, I tried having them share a common TableHeaderModel but this seemed to pose unexpected problems such as only being able to resize using the last table added. I could live with just having their column widths stay in sync while being able to resize using any of the tables if someone has a solution to that.

I have posted a code example below. When run you notice that you can not resize the first or second table headers, but the third one resizes them all. I want the behavior of the third table, but from any of the table headers.

Thank you.

package javaapplication5;

public class NewJFrame extends javax.swing.JFrame {

  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JScrollPane jScrollPane2;
  private javax.swing.JScrollPane jScrollPane3;
  private javax.swing.JTable jTable1;
  private javax.swing.JTable jTable2;
  private javax.swing.JTable jTable3;

  public NewJFrame() {
      initComponents();

      jTable2.setColumnModel(jTable1.getColumnModel());
      jTable3.setColumnModel(jTable1.getColumnModel());        
  }

  private void initComponents() {

      jScrollPane1 = new javax.swing.JScrollPane();
      jTable1 = new javax.swing.JTable();
      jScrollPane2 = new javax.swing.JScrollPane();
      jTable2 = new javax.swing.JTable();
      jScrollPane3 = new javax.swing.JScrollPane();
      jTable3 = new javax.swing.JTable();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(),             
          javax.swing.BoxLayout.Y_AXIS));

      jTable1.setModel(new javax.swing.table.DefaultTableModel(
          new Object [][] {
            {"a", "b", "c", "d"},
            {"e", "f", "g", "h"},
            {"i", "j", "k", "l"},
            {"m", "n", "o", "p"}
          },
          new String [] {
            "Title 1", "Title 2", "Title 3", "Title 4"
          }
      ));
      jScrollPane1.setViewportView(jTable1);

      getContentPane().add(jScrollPane1);

      jTable2.setModel(new javax.swing.table.DefaultTableModel(
          new Object [][] {
            {"q", "r", "s", "t"},
            {"u", "v", "w", "x"},
            {"y", "z", "1", "2"},
            {"3", "4", "5", "6"}
          },
          new String [] {
            "Title 1", "Title 2", "Title 3", "Title 4"
          }
      ));
      jScrollPane2.setViewportView(jTable2);

      getContentPane().add(jScrollPane2);

      jTable3.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {"7", "8", "9", "10"},
            {"11", "12", "13", "14"},
            {"15", "16", "17", "18"},
            {"19", "20", "21", "22"}
        },
        new String [] {
            "Title 1", "Title 2", "Title 3", "Title 4"
        }
      ));
      jScrollPane3.setViewportView(jTable3);

      getContentPane().add(jScrollPane3);

      pack();
  }

  public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
              new NewJFrame().setVisible(true);
          }
      });
  }
}
  • 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-05-15T19:55:52+00:00Added an answer on May 15, 2026 at 7:55 pm

    While waiting for an answer, I stumbled upon a fix to my problem. It is apparently a known bug. I used the solution posted here, with a change in the comments below it.

    https://bugs.java.com/bugdatabase/view_bug?bug_id=4816146

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

Sidebar

Related Questions

I have an interface that defines some methods I would like certain classes to
Using Guava, I would like to have a map that has the following properties:
I have an interface that has large numbers of controls, see image below. Interface
I have an interface that has two toolbars, one attached to the frame and
I have an existing interface that has a JPanel for displaying pdf files. It
I have an interface (called Subject ) that has the following method: public void
In my business model I have Entity class (IPoint interface ) that has a
I have an application which has a similar interface to Visual Studio, in that
I have inherited a project that has an awkwardly big interface declared (lets call
I am developing app that has multiple skins and I have a dilemma on

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.