Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <david_r_whiting@ya...> - 2003-11-17 07:29:44
|
Hi, I have only spent a few hours with Jython but am impressed with how quickly I have been able to develop useful tools (impressed enough to have ordered Jython Essentials). I have no python experience and have only dabbled a little with java, but have managed to create a number of useful tools already. I am now trying to play with JTree objects and am having trouble getting my head around working with events. For example, I would like to popup a menu of actions when the user right-clicks on a node. I have some code (which I butchered from something I found in the archives) which includes the following (i.e. there's stuff before and after this, but I think this is the relevant bit): class myNode(swing.tree.DefaultMutableTreeNode): def __init__(self, ChildName): swing.tree.DefaultMutableTreeNode.__init__(self, mousePressed=self.pressed) self.userObject = ChildName def pressed(self, event): print "Argh! You got me!" rootnode = myNode("Root") child1 = myNode("Child-1") child2 = myNode("Child-2") child1_1 = myNode("Grandchild 1-1") This does not print when I press the mouse on a node. I actually want a right-click anyway but thought I'd have a go at that after getting some sort of response from any kind of click. I have not been able to find examples searching on the, and will have to wait a month before I'll be in the same location as the Jython Essentials I have just ordered. At the moment that feels like a very long time :) Can anyone post an example of how to popup a menu after a right-click on a JTree node to get me going? TIA. Dave ===== David Whiting Data Services Manager Adult Morbidity and Mortality Project (AMMP) Box 65243, Dar es Salaam, Tanzania Tel: +255 22 211 6145 Fax: +255 22 212 3289 Email: dave.ammp@... ________________________________________________________________________ Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk |