This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I know which object is selected?  RSS feed

 
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!