Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: JPopupMenu Date: Mon, 02 Feb 2015 14:46:06 -0500 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <877fw0yuwm.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 2 Feb 2015 19:45:39 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="3870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bwrLl1XnBLcTwXL9A/mLh" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: <877fw0yuwm.fsf@Equus.decebal.nl> Cancel-Lock: sha1:2hn3IO3w4Ow9DdJ3QqdsUFhVORM= Xref: csiph.com comp.lang.java.programmer:31019 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