Results 1 to 2 of 2
- 11-17-2009, 09:55 PM #1Member
- Join Date
- Nov 2009
- Rep Power
Sorting and hiding columns in JTable
I have a Jtable i would like to sort by one particular columns (that is filled with ints). However I do not particularly want the user to see this column. I want them to press a button I have and have that be equivalent to them clicking on this columns header.
in short: can i sort by a hidden column in Jtable and how?
- 11-17-2009, 10:59 PM #2
I think you can hack together a way to do this however it won't be pretty. I could be completely wrong I'm going off pure memory of what's available with a JTable object.
I believe there's a setVisible() method with rows and cols that you can turn off. Also say you have 4 cols and the 4th column has your values you don't want the user to see. You can sort by that column and then put all the values in order into an array and then redraw a new table with only 3 columns and input everything from the array.
I'm assuming each row is an object and each col an attribute of that object so you should be able to resort and repopulate everything using getter methods.Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- By Jeegen in forum AWT / SwingReplies: 7Last Post: 09-23-2009, 08:28 PM
- By mm2236 in forum AWT / SwingReplies: 0Last Post: 04-09-2009, 05:37 PM
- By BLR in forum Advanced JavaReplies: 2Last Post: 03-16-2009, 11:41 AM
- By Laura Warren in forum New To JavaReplies: 2Last Post: 12-18-2008, 10:01 PM
- By Alan in forum AWT / SwingReplies: 2Last Post: 05-14-2007, 06:18 PM