aspose file tools*
The moose likes Java in General and the fly likes problem with popuphandler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem with popuphandler" Watch "problem with popuphandler" New topic
Author

problem with popuphandler

Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
hi,
I've written the following code:

and added this to a List object.
However, when I click on the control it always shows the 'not a popuptrigger' msg, even when I rightclick (which should be the popuptrigger for me).
If I remove the if statement I do get the popupmenu, so that works, but it doesnt recognize my right-clicks as popuptriggers for some reason.
I run WinXP Corporate.

Can someone tell me what the problem is?
TIA
[ February 07, 2004: Message edited by: Maarten Vergouwen ]
Donny Nadolny
Ranch Hand

Joined: Mar 05, 2003
Posts: 32
It will always display "not a popuptrigger" because there is no "else" statement. So as long as mousePressed is called, System.out.println("not a popuptrigger"); will be run. To fix this, change the code to:

Hope this helps.


- Donny Nadolny<br />The pen is mightier than the sword, and considerably easier to write with.
Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
It doesnt.
You're right in that 'not a popuptrigger' always gets printed, but that wasnt really the problem, the problem is that the popuptrigger doesnt get ,err, triggered.
So what I actually want is to know why that doesnt happen (ie, bith lines get printed in my code).
Maarten Vergouwen
Ranch Hand

Joined: Jan 12, 2004
Posts: 60
I've managed to find the problem myself, and I'm thankful to say it wasnt my fault as such
This is a bit of text found in a corrections list to the 'Just Java 2' book:

p.745 the isPopupTrigger() event method *as shown* will always return false
no matter what on Windows. It is a cross platform thing.
Windows sends a PopupTrigger on a mouseReleased event, while Solaris
uses mousePressed. So the listing should include an identical method
body for mouseReleased. Then it all works.
And note the name is "isPopupTrigger()" with an "is" on the front.

oh well.
[ February 08, 2004: Message edited by: Maarten Vergouwen ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem with popuphandler