rowsorter

Java JTable - show rows only which matches the string

跟風遠走 提交于 2019-12-20 03:19:09
问题 I have a JTable populated with data from a database. I have added a search function that display the rows, if word matched to some rows when the data is typed into a JTextField . But at the minute as you type a string or word that do not matches any of the rows data, what I want to do is to hide all the rows, and the JTable will show just the column names. Just like when something matches IT, shows those rows only which has the string that user typed and hide others. Here is my code that I am

JTable AutoCreateRowSorter sorting Numbers As Strings

ⅰ亾dé卋堺 提交于 2019-12-13 17:01:56
问题 I have a JTable: JTable table = new JTable(); String[] colNames = {"c1"}; DefaultTableModel model = new DefaultTableModel(); Integer[] x = new Integer[10]; int[] xi = {0,1,2,3,4,5,6,7,8,9}; for (int i=0; i<10; i++){ x[i]=new Integer(xi[i]); }model.addColumn("c1"); table.setModel(model); table.setEnabled(false); table.setAutoCreateRowSorter(true); JScrollPane scrollpane = new JScrollPane(table); contentPane.add(scrollpane); Now when I load this and click on a column title the rows sort as if

RowSorter not set in renderer

醉酒当歌 提交于 2019-12-12 02:53:43
问题 I implement icon for sorting column in my jTable. I have a button for find result and i implement a default sorting when i launch the worker. Like this : public void refreshStripedViewTable(final List<FlightBox> boxList, final List<FlightBoxModel> boxesModels, final String sortBy) { if (boxList != null && !boxList.isEmpty()) { stripedViewTableModel.setContent(boxesModels); tableRenderer.setStripedViewModelList(boxesModels); final RowSorter<? extends TableModel> sorter = tableFacade

Get column which fires RowSorterEvent

可紊 提交于 2019-12-11 00:35:22
问题 I have a RowSorterListener. I would like to be able to tell which column fires the RowSorterEvent . However when I attempt to get the column, I do not get the output I desire. public class CustomRowSorterListener implements RowSorterListener { JTable table; public CustomRowSorterListener(JTable table) { this.table = table; } @Override public void sorterChanged(RowSorterEvent e) { //Attempt 1 System.out.println(e.getSource()); //Returns RowSorter and not a column //Attempt 2 System.out.println

JTable sorting programmatically only

怎甘沉沦 提交于 2019-12-10 18:21:36
问题 I have a JTable, that is sortable (made it sortable by calling setAutoCreateRowSorter(true) at initialization). I sort this table programmatically and I would like to disable the default event handling on table header, so that the table can be sorted programmatically only . How to achieve it? The working piece of code would be: public class SortTable extends JDialog { private JTable table; DefaultRowSorter<TableModel, String> sorter; public SortTable() { JScrollPane scrollPane = new