Results 1 to 1 of 1
- 12-02-2010, 02:43 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 1
- Rep Power
- 0
Problem with sorting columns using Jtable
i have a database that i build a table from, getting the columns n then the rows to populate this.
i have
and this works on sorting the columns by the header.Java Code:HDTable.setAutoCreateRowSorter(true);
i also haveso that when the user clicks on a row the data is put into text boxes.Java Code:HDTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //retrieving the selected row index int row = HDTable.getSelectedRow(); String model, site, server; model = HDTable.getValueAt(row, 0).toString(); HDdisklabelTb.setText(model); model = HDTable.getValueAt(row, 1).toString(); HDserialTb.setText(model); model = HDTable.getValueAt(row, 2).toString(); HDsizeTb.setText(model); model = HDTable.getValueAt(row, 3).toString(); HDcommentsTb.setText(model);
but when you click a row and then sort the column by clicking on the header, i get a comile time error of
how do I stop the error?XML Code:ArrayIndexOutOfBounds
how can i check if the user has clicked on a row or column.
also how do i set the table to not editable be still enabled.
im using netbeans SE to design this.
Thanks
Similar Threads
-
Sorting and hiding columns in JTable
By ProgrammingPup in forum Advanced JavaReplies: 1Last Post: 11-17-2009, 09:59 PM -
Sorting JTable on more than just the values listed in the columns
By Jeegen in forum AWT / SwingReplies: 7Last Post: 09-23-2009, 07:28 PM -
Sorting JTable (Vectors) Problem
By ramapple in forum AWT / SwingReplies: 6Last Post: 07-06-2009, 11:15 PM -
Right Align columns in JTable
By Laura Warren in forum New To JavaReplies: 2Last Post: 12-18-2008, 09:01 PM -
sort columns in jtable
By Alan in forum AWT / SwingReplies: 2Last Post: 05-14-2007, 05:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks