• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I know which object is selected?

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • 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
 
Steve Lovelace
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Steve
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!