This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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, Avi.
Joined: Feb 18, 2003
Hi,Avi. 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. Yamashita.lee