• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How do I know which object is selected?

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a JTree which is made up of nodes (Tests) and leaves(test steps) when the user clicks on the tree I need to know which item has been selected. However my problem is I am having to cast the selected node to enable me to use it, but obviously need to cast it inot the correct object. I have tried to create a superclass which both the test and the testsep class extend but am still stuck on how I can test to see which type the returned object really is.
Thanks
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use either of these expressions:
selectedNode.isLeaf()
selectedNode.getUserObject() instanceof TestCase
You do need to find this out before cast to TestCase.
[ April 07, 2004: Message edited by: Steve Lovelace ]
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Steve
reply
    Bookmark Topic Watch Topic
  • New Topic