2013-05-07 55 views

回答

6

我不知道有任何API来做到这一点。下面的代码通过查找文件选择器使用的表,然后手工做的那种日期列:

JFrame frame = new JFrame(); 
JFileChooser fileChooser = new JFileChooser("."); 
Action details = fileChooser.getActionMap().get("viewTypeDetails"); 
details.actionPerformed(null); 

// Find the JTable on the file chooser panel and manually do the sort 

JTable table = SwingUtils.getDescendantsOfType(JTable.class, fileChooser).get(0); 
table.getRowSorter().toggleSortOrder(3); 

fileChooser.showOpenDialog(frame); 

您还需要达里尔的Swing Utils类。

+1

+1 Nice hack;) – MadProgrammer 2013-05-07 23:54:55

+0

非常好;谢谢。 – user1359010 2013-05-08 22:59:25