tablerowsorter

JTable RowFilter

夙愿已清 提交于 2019-12-11 07:36:16
问题 Is is possible to some how get the index of the selection corresponding to the non filtered table? After the table is filter using a regexFilter. JTable getSelectedRow returns the index of the filtered table? 回答1: If you are using the built in TableRowSorter functionality from 1.6 you can use the convertRowIndexToModel() on the table. This is give you the unfiltered index of the selected row. The javadoc for JTable gives a description of this: Coordinate conversions will be necessary when

Removing JTable row when sorter is applied causes IndexOutOfBoundsException

眉间皱痕 提交于 2019-12-11 05:28:44
问题 I have a JTable with rows of custom objects, one column of which is a time component that counts down. When the countdown reaches 0 the row is to remove itself automatically. I also have a filter option via textbox that the user can type into to filter the rows by their data. Without the sorter applied to the JTable, everything works correctly (rows removing themselves when the time counts to 0) besides filtering. Applying the sorter gives me an "java.lang.IndexOutOfBoundsException: Invalid

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

JXTable column sorting changes between 1.0 and 1.6

走远了吗. 提交于 2019-12-10 21:07:31
问题 I recently updated the SwingX library in an application from version 1.0 to 1.6.2 since we updated to JDK1.6 . I know the sorting has been changed to re-use some of the Core JDK components which were introduced in JDK 1.6 . However, in version 1.0 it was possible to sort a column by clicking on the header, subsequent clicks reverted the sort order, and shift click removed the sorting and reverted back to the original order. After the update to version 1.6.2, the shift click behavior is no

Is it possible to invoke the auto row sorter in a jtable

荒凉一梦 提交于 2019-12-10 14:17:01
问题 is there anyway to invoke the auto row sorter in a jtable that is created by using setAutoCreateRowSorter(true); i'm trying to get it to sort by a default column without the user having to click on on the column header. 回答1: table.getRowSorter().toggleSortOrder(modelColumnIndex) 回答2: TableRowSorter rowSorter = (TableRowSorter) table.getRowSorter(); List<SortKey> keys = new ArrayList<SortKey>(); SortKey sortKey = new SortKey(2, SortOrder.ASCENDING);//column index 2 keys.add(sortKey); rowSorter

Sorting double values in JTable

▼魔方 西西 提交于 2019-12-10 13:29:47
问题 I have found quite a few questions related to this but I haven't found a simple solution to my issue though. I can't find a way to make my JTable sort Double values properly. I extended AbstractTableModel to receive a Class array and return the proper types per column: class TableModelMod extends AbstractTableModel{ private ArrayList data; private String [] headers; private Class [] types; TableModelMod(String [] heads, ArrayList datas, Class [] classes){ headers = heads; data = datas; types

After adding a TableRowSorter adding values to model cause java.lang.IndexOutOfBoundsException: Invalid range

人走茶凉 提交于 2019-12-03 11:50:44
After adding a TableRowSorter to a table and its corresponding model any corresponding adds specifically at firetabletablerowsinserted cause exceptions. It is clear from testing that the GetRowCount() is returning a value past the models range. However it does not make sense to me how to continue to add values to the table after a sorter or filter has been added? As an example, I set the row filter before adding anything to the table then add a value to the table with the following calls in my model: this.addRow(row, createRow(trans,row)); this.fireTableRowsInserted(this.getRowCount(), this

java JTable sort objects

一曲冷凌霜 提交于 2019-12-02 09:48:14
问题 I am sorry for asking this. But I am having huge problems understanding how to do so. I have a JTable . For that JTable I have my own AbstractTableModel that returns a custom object for getValueAt . Additionally I also have my own TableCellRenderer that uses a lot of colors, and uses column value to extract specified values from object that is given by getValueAt . However I would like to be able to sort values. So how would I go about sorting? I would like to be able to receive the two

Trying to get the sorter positon to retain after a table refresh

假如想象 提交于 2019-12-02 04:49:12
I have the following method: private void passStingR(StringBuilder retVal) throws BadLocationException { int scrollPositionR = scrollR.getVerticalScrollBar().getValue();//get value of scroll position stores in javas memory windowR.remove(scrollR); tableR.getModel(); modelR.setRowCount(0); Document docR = null; try { docR = loadXMLFromString(retVal.toString());//pull in the XML data into a new doc } catch (Exception ex) { Logger.getLogger(remit.class.getName()).log(Level.SEVERE, null, ex); } populate1R(docR); tableR.getTableHeader().setReorderingAllowed(false);//prevent user from changing

JTable Sorting based on hidden column

こ雲淡風輕ζ 提交于 2019-12-02 02:33:35
I would like to sort JTable rows based on one hidden column. Say I have a JTable like this column1 column2 val1 val2 Now I have a one more column3 which is hidden and I dont want to show. When user clicks on Column2 it should sort rows based on Column3 (hidden column) not based Column2. How to achieve this in JTable? you can add by default TableRowSorter to JTable but there is RowSorter , nothing better and clear around as Darryl's Multisort Table Header Cell Renderer note definitions for RowSorter is valid only for concrete TableColumn siple example (with use-less balast again) import java