Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes lost focus in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "lost focus in JTable" Watch "lost focus in JTable" New topic
Author

lost focus in JTable

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
the construction of my table follows this sun java tutorial: i've a custom model and also have two things tutorial refers: a combo inside table cells and also use TableSorter class in order to have sorting.
I use Jtable to display database data, and also use it to have updates, using combo's selected value; i get the selected line, then get the needed values from that row.
what i cant figure out is why i lose focus in selected row (and therefore i cant control my input to updates) when i first click table headers and only after that i select a certain value from a combo: the instant i click combo�s value, row loses focus! - so i'm unable to perform my update, since i ignore my row and its relevant associated data.
i'm using this method to get my row:

how can i turn this around?
TiA


java amateur
Maryam Nouhnejad
Ranch Hand

Joined: Oct 04, 2006
Posts: 39
May be this site can help you...

http://quicktable.org/jtable/quicktablemain.htm
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thank you, Maryam
from what i saw seems a very usefull link

in my concret case, i tried adding the following code to my linha() method: (following a link's idea)

but i get this error:
java.lang.IllegalArgumentException: Row index out of range

dont know what to do
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
at least i found out the reason of last error msg: when i select the cell, all is fine; but when i open combo and click one item, row loses selection and therefore the error msg
my problem is why does it loses selection
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: lost focus in JTable
 
Similar Threads
Jtable Cell and ENTER key
Jtable Event Handling
Dyanmically adding a Row to JTable
jtable
JTable Double click