Sort « JTable « Java Swing Q&A





1. JTable Sort    stackoverflow.com

I know that Jtable can sort by a single column. But is it possible to allow for multiple column sort or do i need to write the code myself? Thanks in advance ...

2. JTable sorting rows in Java 1.5    stackoverflow.com

Is there a simple way to sort rows in a JTable with Java 1.5 (setAutoCreateRowSorter and TableRowSorter appear to be Java 1.6 features)?

3. Live sorting of JTable    stackoverflow.com

I've figured out how to get a JTable to be sorted properly, but I can't figure out how to get it to automatically update the sort order when a table cell ...

4. Sorting JTable programmatically    stackoverflow.com

Is there a way to sort a JTable programmatically? I have my JTable's sort working (with setRowSorter) so that when the user presses any of the columns, the table gets sorted. ...

5. Correctly getting data from a (sorted) JTable    stackoverflow.com

I have developed a basic custom JTableModel as follows

public class CustomTableModel extends DefaultTableModel {
  List<MyClass> data;
  public CustomTableModel(List<MyClass> data) {
    this.data = data;
  }

  ...

6. JTable sort with dual tables to keep in sync in Java 1.4    stackoverflow.com

Is there a way where I can have a parent JTable sort value be passed and set the sort of a child JTable in Java 1.4? What I have is ...

7. How can i sort java JTable with an empty Row and force the Empty row always be last?    stackoverflow.com

I am using JTable with an empty row at the bottom of the table in order to give the ability of adding new line to the table. After insert or writing data ...

8. Initial state of autoCreateRowSorter in Swing JTable    stackoverflow.com

I have this JTable on my Swing app with the autoCreateRowSorter enabled. My table only has 3 columns, two strings and one int, it works well for all of them when ...

9. Java Swing JTable sort    stackoverflow.com

I have a JTable with column headers. When I click on a column header the data gets sorted. This is the default sort behavior. The thing is that I need ...





10. Correctly sorting doubles with JTable    stackoverflow.com

I have a table where the first column contains Strings and the second contains doubles.

    stars = new StarDatabase(path);
    Object[][] data = new Object[stars.size()][2];
  ...

11. How can you disable all sorting code in JTable in 1.6    stackoverflow.com

I have a JTable extension that has been in use since Java 1.3/1.4 in the project that provided things like column reordering and sorting by clicking on the column. We are ...

12. Using auto sort on a JTable and return the correct data    stackoverflow.com

I've got a JTable which model is custom that extends AbstractTableModel. In this the way I get the data is from a list class.

public Object getValueAt(int row, int col)
{
 if ( col ...

13. How do I speed up JTable built in table sorting?    stackoverflow.com

I have a JTable with a custom TableModel that extends AbstractTableModel. I have also used the built in table sorting by calling:

table.setAutoCreateRowSorter(true);
The model also return the right class of the ...

14. How to Keep Track of row index when JTable has been sorted by the user?    stackoverflow.com

I have a JTable which has 1st row blank. Now when I sort the table based on a column by clicking on that column then the blank row goes at the ...

15. JTable renderer with sorting    stackoverflow.com

I am trying to sort a table using rowsorter.

RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
cTable.setRowSorter(sorter);
I am using a renderer which extends DefaultTableCellRenderer. I am using the renderer to paint the contents of the ...

16. jTable and Sorting    stackoverflow.com

How do i sort jtable column using radio button? my jtable is defaultTableModel not vectors. I have already achieve when user press on column header, it will sort, now i have to implement ...





17. Sorting a table breaks the TableRowListener?    stackoverflow.com

I have a sortable default table model with ListSelectionListener that listens for a doubleclick and then opens a details view of a particular column. This works fine, however, when I sort ...

18. JTable + Sorting specific field    stackoverflow.com

I have a JTable and have added sorting. Now the JTable has 5 columns and the 2nd column in a date field converted to DD/MM/YYYY and displayed in a JTextField in ...

19. JTable, RowSorter, getSelectedRow data    stackoverflow.com

I'm using RowSorter in JTable and when I sort one of the column and call the method getSelectedRowData() it return wrong data.

public Object getSelectedRowData()
{
    if(getDataArray() != null)
  ...

20. How to make a JTable sort not on the event thread?    stackoverflow.com

So I have an expensive sort that can use IO or grabbing data from the net to help it sort. My problem is that JTable sort is on the event thread and ...

21. JTable - sorting rendered values    stackoverflow.com

I am using custom renderer to render cell values in JTable. When I perform sorting using my own Comparator or TableRowSorter, values are generally sorted using data from the model. Is there ...

22. How to restore the original row order with JTable's row sorter?    stackoverflow.com

I've enabled sorting in JTable with setAutoCreateRowSorter method. Mouse clicks on the column headers will switch between ascending and descending order, but I would like to switch it between ascending, descending ...

23. How can i sort my JTable using Bubble sort?    stackoverflow.com

I would like to know how to implement Bubble sort onto a DefaultTableModel. (I know there is an auto sorter but i have to use bubble sort.) I already know how ...

24. JTable with less row entries than displayed and sorting issues    stackoverflow.com

I'm using a JTable object to show some datas stored into a database. Now I would like to achieve the following result: The displayed JTable must have at least n (let it be ...

25. Sorting numbers in a JTable    stackoverflow.com

How do I realize sorting of columns containing only numbers in a JTable? There is the class TableRowSorter. Using this, however, leads to the following: for every number the string representation ...

26. Sorting JTable Rows issue    stackoverflow.com

Say I have a JTable with some data in it. A call to table.getValueForCell(row,col) returns the contents of the cell. This is as expected. Now say I want to sort my ...

27. To sort locally or to requery?    stackoverflow.com

I am developing a java application which will be graphically depicting and organizing hundreds of objects. Each of these objects is loaded in from a SQL database, for use in this ...

28. Sorting JTable causes NullPointerException    stackoverflow.com

I have a JTable which, when the appropriate button is clicked, begins to fill with the results of a file tree walk that goes on in the background. This works fine. I ...

29. JTable Sorting and Filtering    stackoverflow.com

I am creating a program that filters the contents of a JTable using two columns. I have used a RowSorter and everything works fine - at least according to what I ...

30. Sorting two JTables simultaneously    stackoverflow.com

I have two JTables built with different objects of same TableModel class. When I click on one column in Table 1 to sort, the requirement is that the other Table 2 ...

31. How to speed up sorting JTable with model that using OracleCachedRowSet?    stackoverflow.com

I am using JTable with model that holds the data in cachedRowSet with OracleCachedRowSet implemetation . In the getValueAt method, i need to use the cachedRowSet.absolute method in order to move the ...

32. JTable Sorting on detailTable with no Default Table Model    forums.netbeans.org

Hi All, New to Netbeans, really need some help. Working on a project using the Netbeans 6.7.1 Database Application default program with the master/detail Table. I query to a masterTable/detailTable from ...

33. Sorting a JTable    forums.netbeans.org

It looks like this is done manually, not programmatic. I solved my problem by putting the data in a database and using a SELECT with ORDER. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof

34. Deleting rows in a sorted JTable    forums.netbeans.org

Hello, In my application, I have a JTable for displaying data. In the JDialog box that owns the JTable, I want to be able to delete some rows (the selected ones) : everything is fine as long as I don't specify a row sorter for my table. When a row sorter is specified, I get an "ArrayIndexOtOfBound" error when I try ...

35. Sorting the rows in a JTable    coderanch.com

Howdy, Check out the "How to Use Tables" tutorial in the main Java Tutorial (you can find it by going to the Java documentation and then to JTable -- the link should be up near the top). Specifically, there's a whole section down near the bottom which deals with TableModels and how to use them. It also comes with code that ...

37. Sorting and inserting data in JTable    coderanch.com

38. sort rows in JTable    coderanch.com

39. Help me.....JTable Sorting    coderanch.com

40. Header for JTable - sort and filter    coderanch.com

Hi, i need a TableHeader for a JTable with one Label field for the column name and a textfield for a column filter. I think it is easy, but i don't find an easy solution at the moment. A few words to explain, what i want to do : I want to filter and sort on a table (like many people ...

41. Table sorting    coderanch.com

42. JTable mutilple sorting    coderanch.com

43. Sorting in JTable    coderanch.com

44. JTable - Sorting rows    coderanch.com

45. Problem on updating the sorted table    coderanch.com

I follow the Sun example on the table sorting. When I update the sorted table, the rows in the Jtable become the un-sorted state. How to solved ? When I use the setValueAt("object",row, col) to set the sorted table cell, it table will come back to un-sorted status and set the row, col on the un-sorted table!!

46. how to sort items in java.awt.List    coderanch.com

47. JTable and sorting    coderanch.com

Hi, is it possible to do sorting with the JTable. I would like to click on a column header and have the data in the table sorted according some order that ie, numbered or alphanumeric. There may be a few columns, any column may be clicked and sorted according to the order of that column- just like excell. if you know ...

48. Sorting JTable Rows    coderanch.com

49. JTable sorting    coderanch.com

50. So is there some sort of "new Swing" in Java 1.5?    coderanch.com

I'm brand new to Java and I'm justr trying to figure out where to start for doing GUIs. From what I've read, if you care anything about having a responsive GUI, you need to avoid Swing. And in my own experience, I've seen the annoying delays that Swing GUIs exhibit - albeit short, but even a half-second delay every time you ...

51. JFile Chooser Sorting    coderanch.com

52. get correct values from sorted jtable    coderanch.com

hi! maybe you guys can help me get the correct row value from a sorted jtable i am able to be a value using getValueAt() but when i sort the table the value i get dont match the one on display. i believe there is an extra step to retrieve the real row, but i dont know how. thanks for advance ...

53. Sorting and adding a row in table    coderanch.com

54. Jtable sorting; problem with getValueAt    coderanch.com

Hi guys, I have implimeneted a sorting JTree (with a TableSorter). Problem is when the user clicks on the column, say length, the sorting is incorrect. (it sorts it as if it's a String; same goes to the sort by dueDate) I understand that the sorting is according to the object's type. the due date is a String in the example ...

55. Sorting of Number.    coderanch.com

56. sort column3 only.    coderanch.com

58. Sorting Complication    coderanch.com

Thanks Ernst, I too have done something similar to what you are telling. But the problem that i am facing i will explain Suppose there are three rows (simplified though) Sorting column 2 after sorting column 1 Step 1: After sorting on column 1 Column 1 Column 2 Column 3 1_Hotel City 3_Rate 2_Hotel City 2_Rate 3_Hotel City 1_Rate Step 2: ...

59. Sort the elements in Tree in SWT    coderanch.com

60. Regarding JTable Sorting    coderanch.com

61. Sorting SWT Tree    coderanch.com

Better to use TreeViewer from JFace. You can use setSorter(). In general, it's better to use the more abstracted JFace and only use the lower level SWT stuff if you can't do something with JFace. BTW... It's far far more efficient to do your sorting at the model level rather than using the ViewerSorter. If you expect to have only a ...

62. Most effective JTable sorting    coderanch.com

Just a thought, but is it not correct that you halt the GUI while the sort happens. Presumably you don't want the user to be making changes while another thread is sorting? Obviously it depends entirely on your implementation, but if you had: Name Telephone number --------------------------- Alan 123423 Brian 4626342 Charles 344735 and the sort starts, then the users changes ...

63. Category wise sorting in JTable    coderanch.com

64. JTable sorting for JSE 5.0    coderanch.com

I always build my table models from List(s) of custom objects. In 1.5 I used to provide a custom Comparator which used to accept the column index and sort directon which were used by the compare method. I also used "\u2191" and "\u2193" in my table header renderers to provide visual clues on last sorted column and sort direction. By this ...

65. Sorting JTable    coderanch.com

Hi all (first post) I have created a small program that acts as a simple football league buti am having difficulty sorting the JTable where the teams are displayed. I have two classes: 1. Input - Enters result and displays a list of results entered 2. Output - Displays a league table where team data is stored (i.e. Team name, games ...

66. Problem with sorting and filtering a JTable    coderanch.com

Dear Ranchers, I have extended JTable with a table class that makes use of both a rowsorter (CustomTableSorter) as well as a custom row filter (CustomRowFilter). The problem I'm having is that, if the filter is changed (other rows are being displayed, more or less rows possible), the sorting should be re-done. I know the tableChanged method is called after the ...

67. Taking controll over sorting in JTable    coderanch.com

68. Sort by java.sql.Timestamp in JTable    coderanch.com

69. A sort of drop down-menu    coderanch.com

I have built some java-apps but i have never done it without my teatcher nearby. Til now. So i am going to build an app where you can click on some text and then get other text underneath. Like having simple FAQ's and the user can only see the questions and when he/she clicks on a question the answer slides down ...

70. Sorting JTable with scientific notation doubles in Win32    coderanch.com

I have quite an opaque problem. I have a regular JTable that I have filled with values coming from a text file, a report. Some of these fields contain double numbers, formatted in the scientific way (e.g. 1.25E-7). My methodology is to parse these strings to a double and fill the table column with the result. On failure to parse the ...

71. idea on how to sort a jtable header with 2 labels    coderanch.com

hi all. i need advice on how to go about a jtable with a column header having 2 labels (i made a custom header renderer) that when clicking any of those 2 will initiate a sort my requirement is that i do not have to put them as separate columns so 1 column with 2 labels (col1 and col2) have values ...

72. In JIDE- Jtable - how to get the actual row index (if the table is sorted row id is changing)    coderanch.com

I have implemented jtable using JIDE, my requirement is I have to select the row as soon as I add a row to the jtable. For this I am getting the current row count and passing that value to select the row. But when i sort the jtable the selection is going wrong. So for this I need the actual row ...

74. Some sort of cursor label    coderanch.com

75. retrieving the event of JTable sorting    coderanch.com

76. Sorting JTable    java-forums.org

77. Sort and filter in Jtable (java ver 1.5 )    java-forums.org

78. Sorting data in a Vector    java-forums.org

Java Code: public void getContacts() throws IOException { { BufferedReader file_in = new BufferedReader(new FileReader("files/Book1.buab")); int count=0; String name = ""; String secondname = ""; String phone = ""; String mobilephone = ""; String address = ""; String email =""; while (true) { String line = file_in.readLine(); switch(count){ case 0: { name = line; } case 1: { secondname = line; ...

79. how to sort 2 tables    java-forums.org

I have 2 JTables and two table models set on these tables. Out of theses one is set as the rowHeader of other. Both the tables have same data. So, I want to sort the rowHeader data by clicking over the column header of the scrollable table. how can I sort this tables at the same time?

80. how to sort jtable with row groups    java-forums.org

Hello All, I am writing my first production application for work, it scrapes data from a telnet session and displays it in a jtable. The data displayed is call disposition statistics for individual agents in a market research center. It provides filtering by center location, and whether the agent is currently active on the project in question. The data displayed may ...

81. Sorting JTable (Vectors) Problem    java-forums.org

Yes, the DefaultTableModel is notified of changes. If not, it would not have displayed information in the first place. I used addNotify() and revalidate() for notifying of its changes. Also, the vector is indeed the same vector as before the sort. I've run a few debug System.out.println() tests and the vector for the JTable is the same.

82. Sorting Three Integers Using JOptionPane    java-forums.org

Hello I Need To Write A Java Code That Gets 3 Integers From The User And Sorts Them From Smallest To Largest And Displays In A JOptionPane Dialog Box. The Code I Have So Far Compiles Fine And Runs Great If I Enter 5, 10, 15 But If I Enter 15, 5, 10 It Returns "The Numbers Arranged From Samllest To ...

83. Gui with sorting names    java-forums.org

84. Adding data to a jTable or some sort    forums.oracle.com

Hi, I'm completely new to Java and I want to add data to a jTable with six columns automaticly but I don't know how. 1. I need a function that generates random data (6 six random strings) 2. Every generated row (those 6 random strings) has to be put in the table once at a time. So you can see the ...

85. sorting JTable    forums.oracle.com

// This comparator is used to sort vectors of data public class ColumnSorter implements Comparator { int colIndex; boolean ascending; ColumnSorter(int colIndex, boolean ascending) { this.colIndex = colIndex; this.ascending = ascending; } public int compare(Object a, Object b) { Vector v1 = (Vector)a; Vector v2 = (Vector)b; Object o1 = v1.get(colIndex); Object o2 = v2.get(colIndex);

86. JTable Sorting issue    forums.oracle.com

88. Jtable sorting - back to original state? simple question    forums.oracle.com

ok so I have a JTable and I implemented a sorting feature in it. let's say this is the original data the table has started with: 8 6 10 5 if the user clicks on that column, column will be sorted in a descending order 10 8 6 5 click again and it will be sorted ascending... 6 5 8 10 ...

89. JTable Sorting    forums.oracle.com

90. Jtable sort question    forums.oracle.com

91. sorting a JTable    forums.oracle.com

I have a JTable that implements a custom renderer. In the renderer I modify the cell foreground and background depending on the data it contains. I just realized that when I sort the grid the colors remain where they are (in space) and do not follow the data. Im assuming I am going to have to keep track of the colors ...

92. Sorting JTable    forums.oracle.com

93. JSE 1.6.0 JTable RowSorter index problem when sort    forums.oracle.com

I have a JTable and im testing the RowSorter , new feature in SE 1.6 and after clik in the column header, the sort works fine, but when i select any row, for example row 5, i get the cell value ( ....jTable1.getValueAt(.... ) from the row that was in the position 5 before the sort. Seem that the table sorts ...

94. Sorting a JTable at runtime    forums.oracle.com

I have a JTable which is populated by a DefaultTableModel. I have attached a TableRowSorter to my JTable. So when I click on a TableHeader the rows in the table are sorted and sort any new or updated rows automatically. Now the issue I'm having is I want to only sort the JTable once only on the user click of the ...