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

  • Home
  • SEARCH
  • 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 8685143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:29:18+00:00 2026-06-12T22:29:18+00:00

I have several JTables with several columns each. Each table is displayed on a

  • 0

I have several JTables with several columns each. Each table is displayed on a different tab in a JTabbed Pane. These columns have the same header name among the tables, but different values in the columns. I am trying to allow the comparison of a header among all of the tables by right clicking a header, and hitting compare. This opens a new JDialog while passing a List of columns with the matching header that was chosen:

public void actionPerformed(ActionEvent arg0) {
                List<TableColumn> columns = new ArrayList<TableColumn>();

                for (int i = 0; i < tables.size(); i++) {

                    String tableName = tabPane.getTitleAt(i);
                    JTable tempTable = (JTable) tables.get(tableName);

                    // Get column at the channel name used
                    TableColumn col = tempTable.getColumn("chosen header");

                    // Add the column to the list of channel columns
                    columns.add(col);
                }

                new comparisonDialog(UI.getFrame(), "chosen header",
                        columns);
            }

This appears to work correctly, storing all of the common columns for the tables into a list that is passed to a new JDialog. It also seems to work when I display a table with these columns in the new JDialog:

JTable table = new JTable();

for (TableColumn col : passedColumnList) {
            col.setHeaderValue(col.getHeaderValue());
            table.addColumn(col);
        }

The correct columns are displayed, however:

  • All of the data in the column is missing
  • The columns seem to be linked to the tables they came from, as
    resizing one resizes the column in the table it came from!

Am I missing something simple here?

  • 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-12T22:29:19+00:00Added an answer on June 12, 2026 at 10:29 pm

    Firstly, data in the tables is controlled by the table model, not by the column model.

    Secondly, a TableColumn has a model of its own (wrapped in a TableColumnModel), changes to the object will be reflected by all those models registered to monitor it (and therefore the views that rely on them).

    You will need to create a new table model containing the rows of data for each column, mapped to the appropriate column.

    Instead of “extracting” the column reference from the underlying tables, you should allow your table model to define the column information.

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

Sidebar

Related Questions

I have several separate instances of the same web application running on different servers
I have several different sites in different hosts and I use the same JS
I have several xml files with different node structure. I want to extract xml
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
I have several different numbers in a group that range in sizes and would
we have several tens of macro enabled excel files, each of those contains few
I have several Select which depend on each other if I select a value
I have several foreach loops after each other in a larger foreach loop.. What
I have several different user controls that get built dynamically and added to a
I have several divs with id=scroll_1, scroll_2, scroll_3, etc... When any of these divs

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.