JTable select problem  
Author Message
pat270881





PostPosted: 2005-4-5 6:03:00 Top

java-programmer, JTable select problem Hello,

I have a great problem with my JTable. I have a JTable with few lines
and two columns. The user can select one line and with the following
statements

int column = tblSearchResults.getSelectedColumn();
int row = tblSearchResults.getSelectedRow();
Object value = tblSearchResults.getValueAt(row,column);

I retrieve the value with which I display details of a second line in a
new window (when the user presses a certain button). The problem is
when I close this new window and want to select a new line the
getSelectedColumn and the getSelectedRow returns always -1 which
says that no line is marked although I have marked a line.

Does anybody know what the problem can be? - it must concern the open
and close of the detail window, because when I omit the code line which
opens the detail window and only make System.out.println's with the
getSelectedColumn and getSelectedRow it will always output the right
line...

thx

pat

 
John McGrath





PostPosted: 2005-4-5 12:48:00 Top

java-programmer >> JTable select problem On 4/4/2005 at 6:02:53 PM, pat270881 wrote:

> I have a great problem with my JTable. I have a JTable with few lines
> and two columns. The user can select one line and with the following
> statements
>
> int column = tblSearchResults.getSelectedColumn();
> int row = tblSearchResults.getSelectedRow();
> Object value = tblSearchResults.getValueAt(row,column);
>
> I retrieve the value with which I display details of a second line in a
> new window (when the user presses a certain button). The problem is
> when I close this new window and want to select a new line the
> getSelectedColumn and the getSelectedRow returns always -1 which
> says that no line is marked although I have marked a line.
>
> Does anybody know what the problem can be?

No, but I suspect that it is not with the 3 lines of code that you have
shown us. If you post a complete, runnable example of the problem, you
can be certain that you will have included the problem code.

--
Regards,

John McGrath