473,542 Members | 7,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reset JTable header

madhoriya22
252 Contributor
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 5806
JosAH
11,448 Recognized Expert MVP
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 Contributor
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 Recognized Expert MVP
@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

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

Similar topics

1
8610
by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a CheckBoxRenderer which extens Checkbox and implements TableCellRenderer. This seems to have done the job, in that the Checkbox is displayed and not the...
1
8961
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column = tblDecisions.getColumnModel().getColumn(0); TableCellRenderer renderer = column.getHeaderRenderer(); column.setCellRenderer(renderer); }
1
7963
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return statement in getTableCellEditorComponent, it never stops there even though I edit cells in the table. Can anyone tell me what I am missing. By the...
0
3133
by: sivaprasad06 | last post by:
Hi, I have a editable combo box editor as a cell editor for JTable. I want use only key board to enter data into jtable. so i am using ALT+Down comobination for making cell editiable in the jtable. when user clicks that combination what ever editor present in that cell will appear. I am using tab for traversing all cells in table.
0
3379
by: nuria | last post by:
hi, I have an editable JTable, when you are editing it and press F8 shows a dialog and then go again to the JTable window but the focus goes to a JtextField component, go with the tab for the rest of the textfields and when have to get the focus again the JTable can´t get it !!! only if I go with the mouse!!!! I am trying all things,...
1
3084
by: Nelson Joseph | last post by:
Hi all, could you please tell me how to add a chechbox in the JTable column header since I am new to Swing please help me.
7
17184
blazedaces
by: blazedaces | last post by:
Hi guys, what I'm I have is a jtable with boolean variables in the first column and text in the next two (checkboxes). I want my tableChanged method to make it so when I check one of the checkboxes then it would change whether that third column is editable or not. I have made a short array that would hold values of either 0 or 1, basically...
5
9773
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array. But i want the table to display the data from a .txt file in which i had stored information in this format. Can anyone please modify the codes and...
3
3760
by: JHuman | last post by:
Hi all. I've defined a custom TableModel so I can use custom types for my JTable. However, because of this, the table's TableColumnModel is totally out of sync with the model (ie. it isn't populated with any column data at all. No TableColumns or anything). This is annoying, since I need some reference to TableColumn objects (to do some column...
0
7384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7665
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5239
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3377
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1790
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.