本文整理匯總了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");
}