Java Code Examples for javax.swing.table.TableRowSorter#setRowFilter()
The following examples show how to use
javax.swing.table.TableRowSorter#setRowFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultsDisplay.java From beautyeye with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: PeakListTableWindow.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public void updateFilter() { List<RowFilter<Object, Object>> rowSorters = new ArrayList<RowFilter<Object, Object>>(); TableRowSorter<PeakListTableModel> sorter = (TableRowSorter<PeakListTableModel>) table.getRowSorter(); String textId = "(?i)" + filterTextId.getText(); String textIdentity = "(?i)" + filterTextIdentity.getText(); String textComment = "(?i)" + filterTextComment.getText(); rowSorters.add(RowFilter.regexFilter(textId, 0)); rowSorters.add(mzFilter); rowSorters.add(rtFilter); rowSorters.add(RowFilter.regexFilter(textIdentity, 3)); rowSorters.add(RowFilter.regexFilter(textComment, 4)); sorter.setRowFilter(RowFilter.andFilter(rowSorters)); table.setRowSorter(sorter); }
Example 3
Source File: SBOLInputDialog.java From iBioSim with Apache License 2.0 | 6 votes |
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() + ")"); }
Example 4
Source File: Gui.java From Qora with MIT License | 6 votes |
public static <T extends TableModel> JTable createSortableTable(T tableModel, int defaultSort, RowFilter<T, Object> rowFilter) { //CREATE TABLE JTable table = new JTable(tableModel); //CREATE SORTER TableRowSorter<T> rowSorter = new TableRowSorter<T>(tableModel); //rowSorter.setSortsOnUpdates(true); rowSorter.setRowFilter(rowFilter); //DEFAULT SORT DESCENDING rowSorter.toggleSortOrder(defaultSort); rowSorter.toggleSortOrder(defaultSort); //ADD TO TABLE table.setRowSorter(rowSorter); //RETURN return table; }
Example 5
Source File: DefaultsDisplay.java From littleluck with Apache License 2.0 | 6 votes |
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); } }
Example 6
Source File: FilteredTableNextRowProviderTest.java From otroslogviewer with Apache License 2.0 | 6 votes |
@Test public void testFilteredTable() { JTable jTable = new JTable(10, 1); TableRowSorter rowSorter = new TableRowSorter(jTable.getModel()); jTable.setRowSorter(rowSorter); RowFilter<TableModel, Integer> rowFilter = new RowFilter<TableModel, Integer>() { public boolean include(Entry<? extends TableModel, ? extends Integer> entry) { return entry.getIdentifier().intValue() % 2 == 0; } }; rowSorter.setRowFilter(rowFilter); NextRowProvider nextRowProvider = NextRowProviderFactory.getNextFilteredTableRow(jTable); for (int i = 0; i < 5; i++) { int nextRow = nextRowProvider.getNextRow(); assertEquals(i * 2, nextRow); } assertEquals(-1, nextRowProvider.getNextRow()); }
Example 7
Source File: bug8032874.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 8
Source File: bug8032874.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 9
Source File: bug8032874.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 10
Source File: bug8032874.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 11
Source File: bug8032874.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 12
Source File: JtableFilter.java From domain_hunter with MIT License | 5 votes |
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); RowFilter<Object, Object> filter = new RowFilter<Object, Object>() { public boolean include(Entry entry) { Integer population = (Integer) entry.getValue(1); return population.intValue() > 3; } }; TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); sorter.setRowFilter(filter); table.setRowSorter(sorter); JScrollPane scrollPane = new JScrollPane(table); JFrame frame = new JFrame("Filtering Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane); frame.setSize(300, 200); frame.setVisible(true); }
Example 13
Source File: bug8032874.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 14
Source File: bug8032874.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 15
Source File: bug8032874.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 16
Source File: bug8032874.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 17
Source File: bug8032874.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void createAndShowUI() { try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { throw new RuntimeException(e); } JFrame frame = new JFrame("bug8032874"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); tableModel = new TestTableModel(); table = new JTable(tableModel); table.setSurrendersFocusOnKeystroke(true); final TableRowSorter<TestTableModel> rowSorter = new TableRowSorter<TestTableModel>(tableModel); rowSorter.setRowFilter(new RowFilter<TestTableModel, Integer>() { @Override public boolean include(Entry<? extends TestTableModel, ? extends Integer> entry) { return entry.getIdentifier() % 2 == 0; } }); table.setRowSorter(rowSorter); JScrollPane jScrollPane = new JScrollPane(table); panel.add(jScrollPane); frame.setContentPane(panel); frame.setSize(new Dimension(800, 600)); frame.setVisible(true); }
Example 18
Source File: Main_CustomersFrame.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
private void filter(String query) { String modifiedQuery = "(?i)" + query; TableRowSorter<TableModel> tr = new TableRowSorter<TableModel>(model); customerTable.setRowSorter(tr); tr.setRowFilter(RowFilter.regexFilter(modifiedQuery)); }
Example 19
Source File: BuscaFornecedor.java From java-sistema-vendas with GNU General Public License v3.0 | 4 votes |
private void tfFiltroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfFiltroKeyReleased TableRowSorter rs = (TableRowSorter) tbGrade.getRowSorter(); rs.setRowFilter(RowFilter.regexFilter("(?i)" + tfFiltro.getText(), 0, 1)); }
Example 20
Source File: BuscaCliente.java From java-sistema-vendas with GNU General Public License v3.0 | 4 votes |
private void tfFiltroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfFiltroKeyReleased TableRowSorter rs = (TableRowSorter) tbGrade.getRowSorter(); rs.setRowFilter(RowFilter.regexFilter("(?i)" + tfFiltro.getText(), 0, 1)); }