Results 1 to 2 of 2
Thread: JTable Cell Focus Listener
- 07-20-2009, 04:05 PM #1
- 07-21-2009, 08:08 AM #2
So far i have added a keyListener to my table and used the keyPressed method to handle the key events. The funny thing is, when i press enter key i get an error
BUT when i use the tab key even when am capturing events for the enter key it works alright:confused:Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Column index out of range
I just dont know why am getting an error
below is my code
Your ideas are highly appreciatedJava Code:public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { int cols = 2; int rows = Xenon.getRowCount(); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { int r =Xenon.getSelectedRow(); int c =Xenon.getSelectedColumn(); if(c < cols) { setSelectedCol(c + 1); return; } if(c == cols) { if(r<rows) { setSelectedRow(r + 1); setSelectedCol(0); Xenon.scrollRectToVisible(Xenon.getCellRect(r + 1, 0, true)); }else { setSelectedRow(rows); setSelectedCol(cols); } } } } public void setSelectedCol(int col) { if(col == -1) return; else { Xenon.setColumnSelectionInterval(col, col); } } public void setSelectedRow(int row) { if(row == -1) return; else { Xenon.setRowSelectionInterval(row, row); } }
Thank youLast edited by Manfizy; 07-21-2009 at 02:07 PM.
We Learn Through Mistakes..,
Manfizy:rolleyes:
Similar Threads
-
JComboBox in JTable and Cant get Focus...
By markw8500 in forum New To JavaReplies: 1Last Post: 03-29-2009, 11:35 PM -
add an undo listener to a Jtable
By christina in forum Advanced JavaReplies: 12Last Post: 01-29-2009, 07:47 AM -
Set focus on particular cell in a JTable when using TableModel
By sridhar_negi in forum AWT / SwingReplies: 0Last Post: 11-14-2008, 04:14 AM -
jTable Cell editing
By mahaling_m in forum AWT / SwingReplies: 0Last Post: 06-23-2008, 08:17 AM -
JTable Focus Traversal
By helios_lie in forum AWT / SwingReplies: 1Last Post: 12-20-2007, 10:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks