aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to set up JTable row listener code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set up JTable row listener code" Watch "How to set up JTable row listener code" New topic
Author

How to set up JTable row listener code

ritesh r
Greenhorn

Joined: Jul 19, 2001
Posts: 24
Hi ALL:

I am a Newbie to Jtable.
I am using the DefaultTableMOdel and the JTable(Vector rows,Vector Col).
Now I am able to display the Data from the SQL Database quite well in my JTable.
Now the problem is how to go about writing a listener to a Selected Row in the JTable.
Please help me with Source COde.
Thanking u.
Sincere Regards
Ritesh
ritesh r
Greenhorn

Joined: Jul 19, 2001
Posts: 24
Hi ALL:
I am a Newbie to Jtable.
I am using the DefaultTableMOdel and the JTable(Vector rows,Vector Col).
Now I am able to display the Data from the SQL Database quite well in my JTable.
Now the problem is how to go about writing a listener to a Selected Row in the JTable.
Please help me with Source COde.
Thanking u.
Sincere Regards
Ritesh
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You need to be more specific on what you are needing.
ritesh r
Greenhorn

Joined: Jul 19, 2001
Posts: 24
Hi Paul
I have populated my JTable in a JInternalFrame.
Now can u help me with writing a listener which would help the user to view the details of a single row.
When a user double-clicks a single row in a JTable,he/she should be able to see the details of that single row.
This code is not working properly.
>>>>>>>>>>>>>>>>>>>Sample Code>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
I have added a MouseListener interface to my class.
jtable.addMouseListener(this);
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
{
int index = jtable.getSelectedRow();
CommentsDialog comp=new CommentsDialog
(Issue_Tracking_t,index);

}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>End of Sample Code>>>>>>>>>>>>>>>>
Here the CommentsDialog is a Dialog Class with the parameters Issue_Tracking_t,which is catching the object populating the Jtable.The index is the selcted row of the populated Jtable.
Why is the double click of the mouse not working.
Looking to hear from you.Tell me whether I am right in choosing the Listener.
Thanking you.
Sincere REgards
R.RItesh
Originally posted by Paul Stevens:
You need to be more specific on what you are needing.

 
jQuery in Action, 2nd edition
 
subject: How to set up JTable row listener code