List of usage examples for javax.swing.table TableRowSorter TableRowSorter
public TableRowSorter(M model)
TableRowSorter
using model
as the underlying TableModel
. From source file:se.trixon.toolbox.geotagger.GeotaggerTopComponent.java
private void init() { openButton.setIcon(Pict.Actions.DOCUMENT_OPEN.get(TOOLBAR_ICON_SIZE)); editToggleButton.setIcon(Pict.Actions.DOCUMENT_EDIT.get(TOOLBAR_ICON_SIZE)); closeButton.setIcon(Pict.Actions.WINDOW_CLOSE.get(TOOLBAR_ICON_SIZE)); closeButton.setEnabled(false);/*from w w w.ja v a 2s. c o m*/ startButton.setIcon(Pict.Actions.ARROW_RIGHT.get(ICON_SIZE)); startButton.setToolTipText(Dict.START.getString()); startButton.setEnabled(false); saveLogButton.setIcon(Pict.Actions.DOCUMENT_SAVE.get(ICON_SIZE)); saveLogButton.setEnabled(false); helpButton.setIcon(Pict.Actions.HELP_CONTENTS.get(ICON_SIZE)); helpButton.setToolTipText(Dict.HELP.getString()); DropTarget dropTarget = new DropTarget() { @Override public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); List<File> droppedFiles = (List<File>) evt.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (droppedFiles.get(0).isFile()) { openFile(droppedFiles.get(0)); } } catch (UnsupportedFlavorException | IOException ex) { } } }; scrollPane.setDropTarget(dropTarget); mTableModel = new GeotagTableModel(); table.setModel(mTableModel); mTableRowSorter = new TableRowSorter<>(mTableModel); table.setRowSorter(mTableRowSorter); TableColumnModel columnModel = table.getColumnModel(); NumericTableCellRenderer cooNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 6); NumericTableCellRenderer altNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 4); columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setCellRenderer(cooNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setCellRenderer(cooNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setCellRenderer(altNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_NAME).setPreferredWidth(200); columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setPreferredWidth(100); columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setPreferredWidth(100); columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setPreferredWidth(50); }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.simulation.SimulationTopComponent.java
public SimulationTopComponent(SimulationFacade simulationFacade, SimulationData simulationData) { initComponents();/*from w w w. ja v a2 s . c om*/ setName(Bundle.CTL_SimulationTopComponent()); setToolTipText(Bundle.HINT_SimulationTopComponent()); putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE); tableModel = ((DefaultTableModel) jXTable1.getModel()); sorterSimRules = new TableRowSorter<TableModel>(jXTable1.getModel()); /** * the first column (index=0) is a hidden column containing ID of a Data * object */ jXTable1.removeColumn(jXTable1.getColumnModel().getColumn(0)); this.simulationFacade = simulationFacade; this.simulationData = simulationData; loadSimulationRules(); }
From source file:sms.Form1Exams.java
/** * Creates new form Form1Exams/*from w ww . j a v a 2 s . co m*/ */ public Form1Exams() { this.table = new JTable(this.model); this.sid = new JTextField(); final TableRowSorter<TableModel> rowSorter = new TableRowSorter(this.table.getModel()); this.table.setRowSorter(rowSorter); sid.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { String text = Form1Exams.this.sid.getText(); if (text.trim().length() == 0) { rowSorter.setRowFilter(null); } else { rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text, new int[0])); } } public void removeUpdate(DocumentEvent e) { String text = Form1Exams.this.sid.getText(); if (text.trim().length() == 0) { rowSorter.setRowFilter(null); } else { rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text, new int[0])); } } public void changedUpdate(DocumentEvent e) { throw new UnsupportedOperationException("Not supported yet."); } }); initComponents(); setSubjectsModel(); setExamsModel(); actionPerformed(); // findUsers(); //action and statechanged listner for term radio buttons //title(); }
From source file:sms.ViewResults.java
/** * Creates new form ViewResults//from w w w . j a va 2 s. c o m */ public ViewResults() { this.table = new JTable(model); this.sid = new JTextField(); final TableRowSorter<TableModel> rowSorter = new TableRowSorter<>(table.getModel()); table.setRowSorter(rowSorter); sid.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { String text = sid.getText(); if (text.trim().length() == 0) { rowSorter.setRowFilter(null); } else { rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } @Override public void removeUpdate(DocumentEvent e) { String text = sid.getText(); if (text.trim().length() == 0) { rowSorter.setRowFilter(null); } else { rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } @Override public void changedUpdate(DocumentEvent e) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); initComponents(); setExamsModel(); setSubjectsModel(); setStreamsModel(); // findUsers(); // sorter(2); }
From source file:sms.ViewResults.java
private void sorter(int column) { TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel()); table.setRowSorter(sorter);/* www . java 2s .c o m*/ List<RowSorter.SortKey> sortKey = new ArrayList<>(); int colToSort = column; sortKey.add(new RowSorter.SortKey(colToSort, SortOrder.DESCENDING)); sorter.setSortKeys(sortKey); sorter.sort(); }
From source file:vista.Venta.java
private void search(String query) { //Create new table sorter for the table TableRowSorter sorter = new TableRowSorter(this.tablaDetalle.getModel()); //Add row filter to the tablerowsorter (regex) sorter.setRowFilter(RowFilter.regexFilter("(?i).*\\Q" + query + "\\E.*")); //Apply the results to the output table this.tablaDetalle.setRowSorter(sorter); }