Re: Problem faced while using TinyLnF
- From: Chanchal <chanchal.jacob@xxxxxxxxx>
- Date: Tue, 24 Jun 2008 21:43:08 -0700 (PDT)
I don't think TableRowSorter has a built-in indicator.
Following is a code i got from java2s.com (http://www.java2s.com/Code/
Java/JDK-6/JTableSorting.htm)
<code>
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
public class JTableSortDemo {
public static void main(String[] args) {
Object[][] data = { { "A", 5 }, { "B", 2 }, { "C", 4 }, { "D",
8 } };
String columnNames[] = { "Item", "Value" };
TableModel model = new DefaultTableModel(data, columnNames) {
public Class<?> getColumnClass(int column) {
return getValueAt(0, column).getClass();
}
};
JTable table = new JTable(model);
TableRowSorter<TableModel> sorter = new
TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane scrollPane = new JScrollPane(table);
JFrame frame = new JFrame("Sorting Table");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(scrollPane);
frame.setSize(300, 200);
frame.setVisible(true);
}
}
</code>
This on actually showing the sort indicators. So it seems that there
is a built in sort indicator, but when the look and feel is changed,
it's not getting displayed
Chanchal
.
- References:
- Problem faced while using TinyLnF
- From: Chanchal
- Re: Problem faced while using TinyLnF
- From: Roedy Green
- Problem faced while using TinyLnF
- Prev by Date: Re: cobbling a ComboBox
- Next by Date: Re: cobbling a ComboBox
- Previous by thread: Re: Problem faced while using TinyLnF
- Next by thread: Re: Problem faced while using TinyLnF
- Index(es):