当前位置: 首页>>代码示例>>Java>>正文


Java TableRowSorter.setRowFilter方法代码示例

本文整理汇总了Java中javax.swing.table.TableRowSorter.setRowFilter方法的典型用法代码示例。如果您正苦于以下问题:Java TableRowSorter.setRowFilter方法的具体用法?Java TableRowSorter.setRowFilter怎么用?Java TableRowSorter.setRowFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.TableRowSorter的用法示例。


在下文中一共展示了TableRowSorter.setRowFilter方法的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;
    }
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:27,代码来源:QuickEntrySearch.java

示例2: 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);
    }
}
 
开发者ID:freeseawind,项目名称:littleluck,代码行数:23,代码来源:DefaultsDisplay.java

示例3: 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() + ")");
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:19,代码来源:SBOLInputDialog.java

示例4: 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());
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:32,代码来源:FilesAndSegmentsUtils.java

示例5: 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);
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:26,代码来源:GuiUtils.java

示例6: 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());
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:27,代码来源:GuiUtils.java

示例7: updateFilter

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private void updateFilter(String filterText) {
	filterText = "(?i)" + filterText;
	@SuppressWarnings({ "rawtypes", "unchecked" })
	TableRowSorter<ComponentDefinitionTableModel> sorter = (TableRowSorter) table.getRowSorter();
	if (filterText.length() == 0) {
		sorter.setRowFilter(null);
	} else {
		try {
			RowFilter<ComponentDefinitionTableModel, 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() + ")");
}
 
开发者ID:SynBioDex,项目名称:SBOLDesigner,代码行数:18,代码来源:PartInputDialog.java

示例8: updateFilter

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private void updateFilter(String filterText) {
	filterText = "(?i)" + filterText;
	@SuppressWarnings({ "rawtypes", "unchecked" })
	TableRowSorter<SequenceTableModel> sorter = (TableRowSorter) table.getRowSorter();
	if (filterText.length() == 0) {
		sorter.setRowFilter(null);
	} else {
		try {
			RowFilter<SequenceTableModel, Object> rf = RowFilter.regexFilter(filterText, 0, 1);
			sorter.setRowFilter(rf);
		} catch (java.util.regex.PatternSyntaxException e) {
			sorter.setRowFilter(null);
		}
	}

	tableLabel.setText("Matching sequences (" + sorter.getViewRowCount() + ")");
}
 
开发者ID:SynBioDex,项目名称:SBOLDesigner,代码行数:18,代码来源:SequenceInputDialog.java

示例9: testFilteredTable

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
@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());
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:21,代码来源:FilteredTableNextRowProviderTest.java

示例10: execute

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void execute(MVCEvent argEvent) {
      	ToggleDisabledUsersEvent event = (ToggleDisabledUsersEvent) argEvent;
      	boolean show = event.show;
      	TableRowSorter<SecurityUserTableModelA> usersSorter = event.model.getUsersSorterA();
      	if(show){
      		usersSorter.setRowFilter(null);
      	}
      	else	
      	{
  	        RowFilter<SecurityUserTableModelA, Object> rf = null;
  	        //If current expression doesn't parse, don't update.
  	        try {
  	            rf = RowFilter.regexFilter("t", 5);
  	        } catch (java.util.regex.PatternSyntaxException e) {
  	            return;
  	        }
  	        usersSorter.setRowFilter(rf);
      	}
      }
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:21,代码来源:ToggleDisabledUsersCommand.java

示例11: actionPerformed

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {

	@SuppressWarnings("unchecked")
	TableRowSorter<TableModel>sorter = (TableRowSorter<TableModel>) getJTableThreadProtocolVector().getRowSorter();
	
	if (ae.getSource()==this.getJRadioButtonNoFilter()) {
		// --- Remove Filter ----------------
		sorter.setRowFilter(null);
		
	} else if (ae.getSource()==this.getJRadioButtonFilterAgents()) {
		// --- Set Filter -------------------		
		RowFilter<Object,Object> agentFilter = new RowFilter<Object, Object>() {
			
			  public boolean include(Entry<? extends Object, ? extends Object> entry) {

				  // --- get column with ThreadDetail-Instance (ThreadName) ---
				  if(entry.getValue(1) instanceof ThreadDetail) {
					  ThreadDetail tt = (ThreadDetail)entry.getValue(1);	
					  if(tt.isAgent() == true) {
						  return true;
					  }
				  }
				  return false;
			 }
		};
		sorter.setRowFilter(agentFilter);
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:ThreadMonitorProtocolTableTab.java

示例12: createAndShowUI

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:bug8032874.java

示例13: button_filtrarActionPerformed

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private void button_filtrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_filtrarActionPerformed
    // TODO add your handling code here:
            // TODO add your handling code here:
        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(((DefaultTableModel) tabla_item.getModel())); 
        sorter.setRowFilter(RowFilter.regexFilter(textfield_filtro.getText()));
        tabla_item.setRowSorter(sorter);
}
 
开发者ID:turing2017,项目名称:Dise-o-2017,代码行数:8,代码来源:IUGestionarItem.java

示例14: LoadingPlaySheetBase

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
protected LoadingPlaySheetBase( LoadingSheetModel mod ) {
	super( mod );
	errorLabel.setBorder( BorderFactory.createEmptyBorder( 0, 5, 0, 5 ) );

	JTable tbl = getTable();

	tbl.getColumnModel().getColumn( 0 ).setCellRenderer( renderer );
	if ( mod.isRel() ) {
		tbl.getColumnModel().getColumn( 1 ).setCellRenderer( renderer );
	}

	ValueTableModel m = getModel();
	TableRowSorter<ValueTableModel> sorter = new TableRowSorter<>( m );
	sorter.setRowFilter( filter );
	tbl.setRowSorter( sorter );

	tbl.getModel().addTableModelListener( new TableModelListener() {

		@Override
		public void tableChanged( TableModelEvent e ) {
			// not sure why we need to reset the renderer so much
			TableColumnModel tcm = tbl.getColumnModel();
			tcm.getColumn( 0 ).setCellRenderer( renderer );
			if ( LoadingPlaySheetBase.this.getLoadingModel().isRel() ) {
				tcm.getColumn( 1 ).setCellRenderer( renderer );
			}

			setErrorLabel();
		}
	} );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:32,代码来源:LoadingPlaySheetBase.java

示例15: createSorter

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/** Get a table row sorter */
@Override
public RowSorter<ProxyTableModel<Controller>> createSorter() {
	TableRowSorter<ProxyTableModel<Controller>> sorter =
		new TableRowSorter<ProxyTableModel<Controller>>(this);
	sorter.setSortsOnUpdates(true);
	LinkedList<RowSorter.SortKey> keys =
		new LinkedList<RowSorter.SortKey>();
	keys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
	sorter.setSortKeys(keys);
	if (isFiltered())
		sorter.setRowFilter(createFilter());
	return sorter;
}
 
开发者ID:CA-IRIS,项目名称:ca-iris,代码行数:15,代码来源:ControllerTableModel.java


注:本文中的javax.swing.table.TableRowSorter.setRowFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。