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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:43:42+00:00 2026-05-25T21:43:42+00:00

i use a DataModel which extends an AbstractTableModel for my Jtable. When i use

  • 0

i use a DataModel which extends an AbstractTableModel for my Jtable.
When i use the constructor JTable main = new JTable(model);
everything works fine but when i add columns to my DataModel and call this.fireTableStructureChanged() the number of columns does not update as can be seen in the following example.

Example

It shows a JTable initialised with my DataModel, which contained 3 rows and 3 columns. The DataModel has been updated to 4 rows and 4 columns but does only show 3 columns.

My Changeevent seems to be wrong because:

JTable.getColumnCount() shows 3
but DataModel.getColumnCount() shows 4

How can i tell the Table that the number of columns has changed and it should repaint them?

  • 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-25T21:43:43+00:00Added an answer on May 25, 2026 at 9:43 pm

    The JTable also has a TableColumnModel which holds all the columns to show. When you add another column to your model, the column model still has the old number of columns unless the table’s autoCreateColumnsFromModel property is set to true (table.setAutoCreateColumnsFromModel(true)).

    The other way would be to manually add another column to the column model.

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

Sidebar

Related Questions

I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class
use this website a lot but first time posting. My program creates a number
I have a question regarding a rather advanced DataModel which I would like to
I have a rather simple data model, but I have a centric entity called
My classes are a DataModel, which uses ID as its PK, and a Map,
I am trying to use NHibernate to map a legacy database which uses a
Let's say I have a northwind database and I use ADO.NET Entity Data Model
I have a data model in Doctrine/symfony. I have a 'Course' which has many
I am trying to use the XMLSerializer with a castle active record class which
Well, not literally, of course, but: I'm new to Flex and I'm trying to

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.