C
clusardi2k
How can I automatically sort a Jtable by a specific column within code, and still allow the user to (later) sort any column by clicking on the specific table header.
Thanks,
Thanks,
How can I automatically sort a Jtable by a specific column within
code, and still allow the user to (later) sort any column by clicking
on the specific table header.
How can I automatically sort a JTable by a specific column within
code, and still allow the user to (later) sort any column by clicking
on the specific table header.
John said:Have you looked at Sorting and Filtering?
<http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting>
You can restore your TableModel's intrinsic order as shown here:
<http://stackoverflow.com/a/5484298/230513>
I've solved this problem. Do you want the details.
Lew said:Oh, I like that site. Thank you.
I'd like to know your preference regarding the tutorial example
<http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.orac
le.com/javase/tutorial/uiswing/examples/components/TableSortDemoProject/src/co
mponents/TableSortDemo.java>
(and ain't the "tutorial/displayCode.html" cool, huh?)
Do you prefer
public class TableSortDemo extends JPanel {
public TableSortDemo() {
super(new GridLayout(1,0));
as they do it, or
public class TableSortDemo {
JPanel sorterPanel = new JPanel(new GridLayout(1,0));
etc.?
Also,
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
'Class<?>' or don't bother?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.