本文整理汇总了Java中javax.swing.JTable.setAutoCreateRowSorter方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setAutoCreateRowSorter方法的具体用法?Java JTable.setAutoCreateRowSorter怎么用?Java JTable.setAutoCreateRowSorter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setAutoCreateRowSorter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStatsTable
import javax.swing.JTable; //导入方法依赖的package包/类
private JPanel createStatsTable(String title, Map<String, String> data) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(new JLabel(title), BorderLayout.PAGE_START);
StatisticsModel model = new StatisticsModel();
model.setData(data);
JTable table = new JTable(model);
table.setAutoCreateColumnsFromModel(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
table.setAutoCreateRowSorter(true);
JScrollPane scrollPane = new JScrollPane(table);
table.addNotify();
scrollPane.getViewport().setOpaque(false);
scrollPane.getColumnHeader().setOpaque(false);
panel.add(scrollPane, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(300, (data.size()+2)*17));
return panel;
}
示例2: TableSortDemo
import javax.swing.JTable; //导入方法依赖的package包/类
public TableSortDemo() {
super(new GridLayout(1, 0));
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setFillsViewportHeight(true);
table.setAutoCreateRowSorter(true);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
// Add the scroll pane to this panel.
add(scrollPane);
}
示例3: BracketingList
import javax.swing.JTable; //导入方法依赖的package包/类
public BracketingList(String cname, int size)
{
super(new MigLayout("fill"), false);
model = new BracketingListModel();
required = size;
spinner = new JSpinner(new SpinnerNumberModel(size, size/2+1, size, 1));
spinner.addChangeListener(this);
ladiesCheck = new JCheckBox("Ladies Classes", true);
ladiesCheck.addChangeListener(this);
openCheck = new JCheckBox("Open Classes", true);
openCheck.addChangeListener(this);
bonusCheck = new JCheckBox("Bonus Style Dialins", true);
bonusCheck.addChangeListener(this);
table = new JTable(model);
table.setAutoCreateRowSorter(true);
table.setDefaultRenderer(Double.class, new D3Renderer());
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
table.getColumnModel().getColumn(0).setMaxWidth(50);
table.getColumnModel().getColumn(1).setMaxWidth(200);
table.getColumnModel().getColumn(2).setMaxWidth(200);
table.getColumnModel().getColumn(3).setMaxWidth(75);
table.getColumnModel().getColumn(4).setMaxWidth(75);
mainPanel.add(new JLabel("Number of Drivers"), "split");
mainPanel.add(spinner, "gapbottom 10, wrap");
mainPanel.add(ladiesCheck, "wrap");
mainPanel.add(openCheck, "wrap");
mainPanel.add(bonusCheck, "gapbottom 10, wrap");
mainPanel.add(new JLabel("Click on column header to sort"), "center, wrap");
mainPanel.add(new JScrollPane(table), "width 400, height 600, grow");
}