This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable row selection 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 "JTable row selection" Watch "JTable row selection" New topic
Author

JTable row selection

Kevin Hamrick
Ranch Hand

Joined: Aug 30, 2004
Posts: 32
I am trying to give the user the option of selecting a specific row and having the mouseclick return an int value for the row each time they click. It seems from reading the API and other examples that this is something that should be easy to implement but in all honesty I have not been able to do it. I would post my code but I have tried several different things. If someone has done this could you please show me how?
Thanks
Kevin Hamrick
Ranch Hand

Joined: Aug 30, 2004
Posts: 32
Found a solution here right after posting

http://www.iam.ubc.ca/guides/javatut99/uiswing/components/table.html#selection.
This is the code

Only problem is, it seems to be executing the else twice for each click. I thought it might be my mouse but I've change the properties and it still calls the else twice. ANy ideas on why?
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
I'm not sure what you're doing but it's not all that difficult.

Maybe you are getting mouse Up and mouse Down events of some sort.

Here is a quick and dirty example:

 
wood burning stoves
 
subject: JTable row selection
 
Similar Threads
row is selected just clicking on row of a table
select first child element values
Mulitple fo:page-sequence
updateable and scrollable resultset for oracle driver
how to insert row in POI hssf