• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JTable row selection

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

reply
    Bookmark Topic Watch Topic
  • New Topic