hi, m working with jtable in netbeans ide6.5... on insertion the value is inserted in asecending order whereas i need the latest value on insertion to be the first one i.e.descending order...plzz help me..m stuck up n not able to resolve it
Printable View
hi, m working with jtable in netbeans ide6.5... on insertion the value is inserted in asecending order whereas i need the latest value on insertion to be the first one i.e.descending order...plzz help me..m stuck up n not able to resolve it
Your question makes no sense and does not have nearly enough information to make reasonable suggestion. Data is displayed in the order you build the TableModel. If you are using sorting then data is sorted in the appropriate order. If you don't like it ascending, then change the sort order to descending.
thanks for the reply..
m actually new to the netbeans enviornment.. i have binded JTable component to my database table. while inserting the values from the GUI, i wish to insert it in desc format. can u plz tel me how to change the tablemodel or where to change the the sorting manner?? i tried but couldnt find anything specific!!
Well, the classes that bind the table to the database are not core JDK classes so I don't know how they work. But I would guess you need to customize your SQL query to do what you want.
If the JTable is built on a DefaultTableModel,
and if rows are added with its add() method,
switch to the insert() method and put the row where you want it.
This is model-based ordering of the data.
Data can also be ordered strictly within the view.
See JTable.setRowSorter() and the TableRowSorter class.