File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes The Header Of JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "The Header Of JTable" Watch "The Header Of JTable" New topic

The Header Of JTable

yamashita lee

Joined: Feb 18, 2003
Posts: 3
Excuse Me,
I have a problem as the following.
In AbstractTableModel,the cell's editalbe can be set by the function [ isCellEditable(int,int) ].If I want to edit the header of each column same as editing a cell,how can I do? Please give me some adivices.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi Yamashita,
As far as I know, you cannot edit the "JTableHeader". I can't imagine why you would want to.
This is just a suggestion for a possible workaround -- but note that I haven't tried it myself, so I can't really help you much with the implementation of this suggestion.
Perhaps you could not display the "JTableHeader" at all, and set up the first row of your "JTable" so that it looked like the "JTableHeader" -- then you could make that editable, and thus give the impression that the "JTableHeader" is editable.
I know that if you don't place your "JTable" in a "JScrollPane" (just put it in a "JPanel" instead), then the "JTableHeader" is not displayed.
Hope this helps.
Good Luck,
yamashita lee

Joined: Feb 18, 2003
Posts: 3
Thanks a lot for you help.I think your suggestion is useful to my problem.Now I am trying it.
These days I am making a tool for editing csv-file.Before the csv is made,I don't know number of it's rows and columns,of course inculdes the title.So I'd better edit header of the JTable.
I have ever thought another way this morning.Maybe can add a Mouse event on the header,after click the right-key,a popup-panel with a textfield will be out.I can input header's value into this textfield,then press "ok" button for returning the value to header and accomplish the editing.But by this way,the operation of my tool must become complex,so if your suggestion can be successed, it must be my first choice.
Thank you very much.
I agree. Here's the link:
subject: The Header Of JTable
It's not a secret anymore!