Solved

How to change JTable column names "on the fly"?

Posted on 2014-04-02
5
392 Views
Last Modified: 2014-04-03
Hello!

For a Java project, I need to rename the JTable columns on the fly. I wrote a small test code, where the change of the column names becomes visible only when one clicks on the column name.

Can you tell what to do so that the column name changes whenever the first row content is changed?

Thank you for your support!
ASimpleMouseListener.java
RenameTableColumnNames.java
0
Comment
Question by:sae1962at
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 39973005
Can you tell what to do so that the column name changes whenever the first row content is changed?
You need a TableModelListener to do that
0
 
LVL 1

Author Comment

by:sae1962at
ID: 39973101
I am using a TableModelListener now, but still have problems, as you can see when executing the attached code. Again, the column name change is visualized when clicking on any column name, but not before.
RenameTableColumnNames.java
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39973410
After the loop, try calling

table.getTableHeader().repaint();

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39974315
:)
0
 
LVL 1

Author Comment

by:sae1962at
ID: 39974787
Here is the example that fits better to the project framework I am working with. I post it just to have the complete answer for me.
PanelView.java
RenamePanelTableColumnNames.java
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question