本文整理汇总了Java中javax.swing.table.TableRowSorter类的典型用法代码示例。如果您正苦于以下问题:Java TableRowSorter类的具体用法?Java TableRowSorter怎么用?Java TableRowSorter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableRowSorter类属于javax.swing.table包,在下文中一共展示了TableRowSorter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processQuickTextField
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
/**
* This takes care of the processing required to validate the quickTextField
* input and send out a CAR_ADD event.
*/
private void processQuickTextField()
{
String carText = entry.getText().trim();
try
{
if (carText.length() > 0)
Integer.parseInt(carText);
TableRowSorter<EntryModel> sorter = new TableRowSorter<EntryModel>((EntryModel)cars.getModel());
sorter.setRowFilter(new QuickEntryFilter(carText));
cars.setRowSorter(sorter);
int visible = sorter.getViewRowCount();
if (visible > 0 && visible < 10)
cars.setRowSelectionInterval(0, 0);
else
cars.clearSelection();
}
catch(NumberFormatException fe)
{
log.warning("\bThe provided registration card # is not a number ("+carText+").");
return;
}
}
示例2: createPrimerciTable
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
private void createPrimerciTable(){
primerciTableModel = new PrimerciTableModel();
primerciTable = new JTable(primerciTableModel);
primerciTable.setRowSorter(new TableRowSorter<PrimerciTableModel>(primerciTableModel));
primerciScrollPane = new JScrollPane(primerciTable);
listSelModel = primerciTable.getSelectionModel();
adjustInventarColumnWidth();
listSelModel.addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
handleListSelectionChanged();
}
});
primerciTable.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke) {
handleKeys(ke);
}
});
}
示例3: ParameterTablePanel
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
ParameterTablePanel(JHVEventParameter[] parameters) {
setLayout(new BorderLayout());
ParameterTableModel parameterModel = new ParameterTableModel(parameters);
JTable table = new WrappedTable();
table.setModel(parameterModel);
table.setAutoCreateRowSorter(true);
table.getColumnModel().getColumn(0).setResizable(false);
table.getColumnModel().getColumn(0).setMaxWidth(180);
table.getColumnModel().getColumn(0).setPreferredWidth(180);
table.getColumnModel().getColumn(1).setPreferredWidth(200);
table.getColumnModel().getColumn(1).setCellRenderer(new WrappedTextRenderer());
table.setPreferredScrollableViewportSize(new Dimension(table.getWidth(), 150));
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableRowSorter<ParameterTableModel> sorter = new TableRowSorter<>(parameterModel);
sorter.toggleSortOrder(0);
table.setRowSorter(sorter);
table.addMouseMotionListener(this);
table.addMouseListener(this);
add(new JScrollPane(table), BorderLayout.CENTER);
}
示例4: MetaDataDialog
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
public MetaDataDialog(ImageLayer layer) {
super(ImageViewerGui.getMainFrame(), "Image Information");
exportFitsButton.setEnabled(false);
setMetaData(layer);
TableRowSorter<TableModel> sorter = new TableRowSorter<>(fitsModel);
JTable fitsTable = new JTable(fitsModel);
fitsTable.setRowSorter(sorter);
setInitFocusedComponent(fitsTable);
SearchableUtils.installSearchable(fitsTable);
JTextArea basicArea = new JTextArea(basicSB.toString().trim());
basicArea.setEditable(false);
JTextArea hvArea = new JTextArea(hvSB.toString().trim());
hvArea.setEditable(false);
hvArea.setLineWrap(true);
hvArea.setWrapStyleWord(true);
content.add(new JScrollPane(basicArea));
content.add(new JScrollPane(fitsTable));
content.add(new JScrollPane(hvArea));
}
示例5: initializeLocalVars
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
protected void initializeLocalVars()
{
super.initializeLocalVars();
Enumeration<TableColumn> e = getColumnModel().getColumns();
int i = 0;
while(e.hasMoreElements() && i < attributes.length) {
e.nextElement().setCellRenderer(new NameTableCellRenderer(attributes[i++]));
}
getColumnModel().getColumn(0).setMinWidth(0);
getColumnModel().getColumn(0).setPreferredWidth(3);
TableRowSorter<NameTableModel/*<T>*/> sorter =
new TableRowSorter<NameTableModel/*<T>*/>((NameTableModel/*<T>*/)getModel());
for (NameUsageAttribute attribute : attributes) {
sorter.setComparator(attribute.ordinal(), new NameUsageAttributeComparator(attribute));
}
setRowSorter(sorter);
setDragEnabled(true);
}
示例6: createFilterControl
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
protected JComponent createFilterControl() {
onlyVisualsCheckBox = new JCheckBox("Show Only Visual Defaults");
onlyVisualsCheckBox.setSelected(true);
onlyVisualsCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
boolean showOnlyVisuals = onlyVisualsCheckBox.isSelected();
for(int i = 0; i < tabPane.getTabCount() ; i++) {
JScrollPane scrollpane = (JScrollPane)tabPane.getComponentAt(i);
JTable table = (JTable)scrollpane.getViewport().getView();
TableRowSorter sorter = (TableRowSorter)table.getRowSorter();
sorter.setRowFilter(showOnlyVisuals? visualsFilter : null);
}
}
});
return onlyVisualsCheckBox;
}
示例7: initFilters
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
protected void initFilters(JTable table) {
TableRowSorter sorter = new TableRowSorter(table.getModel());
table.setRowSorter(sorter);
if (visualsFilter == null) {
visualsFilter = new RowFilter<UIDefaultsTableModel,Integer>() {
public boolean include(Entry<? extends UIDefaultsTableModel, ? extends Integer> entry) {
UIDefaultsTableModel model = entry.getModel();
Object defaultsValue = model.getValueAt(entry.getIdentifier().intValue(),
UIDefaultsTableModel.VALUE_COLUMN);
return defaultsValue instanceof Color ||
defaultsValue instanceof Font ||
defaultsValue instanceof Icon;
}
};
}
if (onlyVisualsCheckBox.isSelected()) {
sorter.setRowFilter(visualsFilter);
}
}
示例8: TableData
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
public TableData(DefaultTableModel defaultTableModel) {
super(defaultTableModel);
setAutoCreateRowSorter(true);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
((DefaultTableModel) getModel()).setDataVector(new String[1][7],
columnName);
getTableHeader().setResizingAllowed(true);
getColumnModel().getColumn(0).setPreferredWidth(70);
getColumnModel().getColumn(1).setPreferredWidth(255);
getColumnModel().getColumn(2).setPreferredWidth(215);
getColumnModel().getColumn(3).setPreferredWidth(60);
getColumnModel().getColumn(4).setPreferredWidth(90);
getColumnModel().getColumn(5).setPreferredWidth(100);
getColumnModel().getColumn(1).setCellRenderer(
new ItalicCellRenderer());
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
this.getModel());
setRowSorter(sorter);
sorter.setComparator(4, new StringComparator());
sorter.setComparator(5, new StringComparator());
sorter.setComparator(6, new StringComparator());
}
示例9: TableData
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
public TableData(DefaultTableModel defaultTableModel) {
super(defaultTableModel);
setAutoCreateRowSorter(true);
getTableHeader().setReorderingAllowed(false);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
getTableHeader().setResizingAllowed(true);
((DefaultTableModel) getModel()).setDataVector(
new String[1][9], columnName);
getColumnModel().getColumn(0).setPreferredWidth(70);
getColumnModel().getColumn(1).setPreferredWidth(255);
getColumnModel().getColumn(2).setPreferredWidth(215);
getColumnModel().getColumn(3).setPreferredWidth(60);
getColumnModel().getColumn(4).setPreferredWidth(45);
getColumnModel().getColumn(5).setPreferredWidth(45);
getColumnModel().getColumn(6).setPreferredWidth(70);
getColumnModel().getColumn(7).setPreferredWidth(70);
getColumnModel().getColumn(8).setPreferredWidth(100);
getColumnModel().getColumn(1).setCellRenderer(
new ItalicCellRenderer());
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
this.getModel());
sorter.setComparator(4, new StringComparator());
sorter.setComparator(5, new StringComparator());
sorter.setComparator(6, new StringComparator());
setRowSorter(sorter);
}
示例10: TaulaPanela
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
public TaulaPanela(String mota, String izena) {
this.setLayout(new BorderLayout());
if (mota.equalsIgnoreCase("Kautotu"))
gureModeloa = new KautotuTaulaModeloa(izena);
else
gureModeloa = new RankingTaulaModeloa(mota);
gureTaula = new ZebraJTable(gureModeloa);
gureTaula.setCellSelectionEnabled(true);
ListSelectionModel cellSelectionModel = gureTaula.getSelectionModel();
cellSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
cellSelectionModel.addListSelectionListener(this);
gureTaula.setRowSorter(new TableRowSorter<>(gureModeloa));
gureJScrollPane = new JScrollPane(gureTaula);
gureJScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gureJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
this.add(gureJScrollPane, BorderLayout.CENTER);
}
示例11: updateFilter
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
private void updateFilter(String filterText)
{
filterText = "(?i)" + filterText;
@SuppressWarnings({ "rawtypes", "unchecked" })
TableRowSorter<TopLevelTableModel> sorter = (TableRowSorter) table.getRowSorter();
if (filterText.length() == 0) {
sorter.setRowFilter(null);
} else {
try {
RowFilter<TopLevelTableModel, Object> rf = RowFilter.regexFilter(filterText, 0, 1);
sorter.setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException e) {
sorter.setRowFilter(null);
}
}
tableLabel.setText("Matching parts (" + sorter.getViewRowCount() + ")");
}
示例12: EncodeTableModel
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
public EncodeTableModel(String [] headings, List<EncodeFileRecord> records) {
this.records = records;
List<String> tmp = new ArrayList<String>();
tmp.add(""); // Checkbox heading
for(String h : headings) {
String heading = h.trim();
if(heading.length() > 0 && !"path".equals(heading)) {
tmp.add(heading);
}
}
//tmp.add("path");
columnHeadings = tmp.toArray(new String[tmp.size()]);
sorter = new TableRowSorter<EncodeTableModel>(this);
sorter.setStringConverter(new TableStringConverter() {
@Override
public String toString(TableModel model, int row, int column) {
final Object value = model.getValueAt(row, column);
return value == null ? "" : value.toString();
}
});
}
示例13: segmentsTableFilterOnFirstLevel
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
/**
* filtra la tabella dei segmenti sui segmenti classificati sul primo
* livello
*
* @param semGui frame
* @param level livello
*/
public static void segmentsTableFilterOnFirstLevel(SemGui semGui, int level) {
TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) semGui.getSegmentsTable().getRowSorter();
sorter.setRowFilter(new RowFilter() {
@Override
public boolean include(RowFilter.Entry entry) {
String idSeg = (String) entry.getValue(0);
Integer id = Integer.parseInt(idSeg.substring(0, idSeg.indexOf(".")));
SemDocument dto = semGui.getTableData().get(id);
if (dto != null) {
List<ClassificationPath> cpl = dto.getClassPath(idSeg);
if (cpl.size() > 0) {
if (cpl.get(0).getScore()[level] == 0) {
return true;
}
} else {
return true;
}
}
return false;
}
});
semGui.getSegmentsTable().setRowSorter(sorter);
semGui.getStatusSegments().setText("Totale filtrati elementi: " + semGui.getSegmentsTable().getRowCount());
}
示例14: filterTable
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
/**
* gestisce filtri multicampo sulla tabella
*
* @param table tabella
* @param text testo cercato
* @param idxs elenco degli id dei campi dove cercare
*/
public static void filterTable(JTable table, String text, int idxs[]) {
TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) table.getRowSorter();
List<RowFilter<TableModel, Integer>> filters = new ArrayList<>(idxs.length);
if (text != null && text.length() > 0) {
for (int idx : idxs) {
table.getColumnModel().getColumn(idx).setCellRenderer(new JTableCellRender(text));
RowFilter<TableModel, Integer> filterC1 = RowFilter.regexFilter("(?i)" + text, idx);
filters.add(filterC1);
}
RowFilter<TableModel, Integer> filter = RowFilter.orFilter(filters);
sorter.setRowFilter(filter);
} else {
sorter.setRowFilter(null);
}
table.setRowSorter(sorter);
}
示例15: filterOnStatus
import javax.swing.table.TableRowSorter; //导入依赖的package包/类
/**
* gestisce i filtri sullo stato
*
* @param filter1 primo filtro
* @param filter2 secondo filtro
* @param semGui frame
*/
public static void filterOnStatus(String filter1, String filter2, SemGui semGui) {
if (semGui.isIsClassify()) {
return;
}
TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) semGui.getSegmentsTable().getRowSorter();
sorter.setRowFilter(new RowFilter() {
@Override
public boolean include(RowFilter.Entry entry) {
String val = (String) entry.getValue(6);
if (filter2 == null) {
return filter1.equals(val);
} else {
return filter1.equals(val) || filter2.equals(val);
}
}
});
semGui.getSegmentsTable().setRowSorter(sorter);
semGui.getStatusSegments().setText("Totale filtrati elementi: " + semGui.getSegmentsTable().getRowCount());
}