469,282 Members | 1,923 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

How to reset JTable header

madhoriya22
252 100+
Hi,
I am setting the JTable header using setModel() method. Before that I am setting method setAutoCreateColumnsFromModel(boolean) to false. After this I want to change the column header names for localization. But method setAutoCreateColumnsFromModel(boolean) is not allowing to change the column headers, If I change it to true then it changes the layout of the table.

Please suggest any way to change the column header names without changing the layout.

Thanks in advance.

regards,
Amit
Feb 2 '09 #1
3 5225
JosAH
11,448 Expert 8TB
Given the table get the TableColumnModel; given that object get the TableColumns and use the setHeaderValue() method to set the new column headers.

kind regards,

Jos
Feb 2 '09 #2
madhoriya22
252 100+
Hi,
I tried your suggestions, it solved the problem but when I added the new data using addColumn() method. ... it added two new columns in the Jtable but I want to replace the existing columns with the new columns and I am not able to find the way to do it ... Please suggest ?

thanks and regards,
Amit.
Feb 2 '09 #3
JosAH
11,448 Expert 8TB
@madhoriya22
That is an entirely different problem; you can only append or remove columns; you can't directly replace them. Better install an entirely new TableModel.

kind regards,

Jos
Feb 2 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ben Munday | last post: by
1 post views Thread by asd | last post: by
1 post views Thread by raysaun | last post: by
reply views Thread by sivaprasad06 | last post: by
reply views Thread by nuria | last post: by
1 post views Thread by Nelson Joseph | last post: by
3 posts views Thread by JHuman | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.