Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31019
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: JPopupMenu |
| Date | 2015-02-02 14:46 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <maok53$3ou$1@dont-email.me> (permalink) |
| References | <877fw0yuwm.fsf@Equus.decebal.nl> |
On 2/2/2015 2:29 PM, Cecil Westerhof wrote:
> I tried the code at:
> http://www.java2s.com/Code/Java/Swing-JFC/CreatingpopupmenuswithSwing.htm
>
> The JTextField is shown, but the JPopupMenu not. What is wrong in the
> code?
My guess is that the isPopupTrigger() method returns false, perhaps
because the system's/browser's UI doesn't report it as such. In more
modern Java (the code is from a thirteen-year-old book ...) there's a
different, component-specific method: JPopupMenu.isPopupTrigger()
instead of MouseEvent.isPopupTrigger().
It's also worth noting (probably not involved with your problem, but
one never knows) that the example constructs Swing components in code
that does not execute on the Event Dispatch Thread (EDT). In technical
jargon, this is known as a "No-No." See
http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JPopupMenu Cecil Westerhof <Cecil@decebal.nl> - 2015-02-02 20:29 +0100
Re: JPopupMenu Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-02-02 14:46 -0500
Re: JPopupMenu Arne Vajhøj <arne@vajhoej.dk> - 2015-02-02 15:01 -0500
Re: JPopupMenu Cecil Westerhof <Cecil@decebal.nl> - 2015-02-03 01:05 +0100
Re: JPopupMenu Roedy Green <see_website@mindprod.com.invalid> - 2015-02-05 13:34 -0800
Re: JPopupMenu Cecil Westerhof <Cecil@decebal.nl> - 2015-02-10 19:54 +0100
csiph-web