Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with popuphandler

 
Maarten Vergouwen
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maarten Vergouwen
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic