Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #962
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | phillip.s.powell@gmail.co.remove-dii-this |
| Subject | PopupMenuListener event o |
| Message-ID | <1171656855.396238.100790@v33g2000cwv.googlegroups.com> (permalink) |
| X-Comment-To | comp.lang.java.help,comp. |
| Newsgroups | comp.lang.java.gui |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 100 |
| Date | Wed, 27 Apr 2011 15:30:35 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303918235 96.60.20.240 (Wed, 27 Apr 2011 10:30:35 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:30:35 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:962 |
Show key headers only | View raw
To: comp.lang.java.help,comp.
<blockquote>
<pre>
[code]
// webAddressBox IS OF TYPE javax.swing.JComboBox
webAddressBox.addPopupMenuListener(new PopupMenuAdapter() {
/** @uses {@link
com.ppowell.tools.ObjectTools.SimpleBrowser.Surf} */
final Surf surf = new
Surf(webAddressBox.getSelectedItem().toString());
/**
* Perform {@link #surf} processing
* @param evt {@link javax.swing.event.PopupMenuEvent}
*/
public void
popupMenuWillBecomeInvisible(PopupMenuEvent evt) {
System.out.println("you selected:");
surf.doURLProcessing();
}
});
/*
* PopupMenuAdapter.java
*
* Created on February 16, 2007, 11:53 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.ppowell.tools.ObjectTools.SwingTools;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
/**
* Will allow for greater flexibility by implementing {@link
javax.swing.event.PopupMenuListener}
* @author Phil Powell
* @version JDK 1.6.0
*/
public abstract class PopupMenuAdapter implements PopupMenuListener {
/** Creates a new instance of PopupMenuAdapter */
public PopupMenuAdapter() {}
/**
* Overrides {@link javax.swing.event.PopupMenuListener} method
popupMenuCanceled
* @param evt {@link javax.swing.event.PopupMenuEvent}
*/
public void popupMenuCanceled(PopupMenuEvent evt) {}
/**
* Overrides {@link javax.swing.event.PopupMenuListener} method
popupMenuWillBecomeInvisible
* @param evt {@link javax.swing.event.PopupMenuEvent}
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {}
/**
* Overrides {@link javax.swing.event.PopupMenuListener} method
popupMenuWillBecomeVisible
* @param evt {@link javax.swing.event.PopupMenuEvent}
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {}
}
[/code]
</pre>
</blockquote>
This code is supposed to handle a single selection from a JComboBox
webAddressBox. The front-end functionality of this code blocks works
just fine to the user, however, upon viewing the "behind the scenes
action", I noticed that the overriden popupMenuWillBecomeInvisible()
method within the anonymous inner class instance of PopupAdapter is
being called 2 times upon the first time you select something from
webAddressBox, 4 times the next time you select something, 8 times the
next time, and so on..
Obviously this is a tremendous waste of resources to have it call that
many times exponentially - it should only call once each time you
select something from webAddressBox, but I can't figure out how to get
that to happen.
What suggestions might you have to accomplish this? I already have an
ActionListener that runs separately from PopupMenuAdapter that handles
the user either clicking a JButton or hitting ENTER - this works just
fine.
Thanx
Phil
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar
PopupMenuListener event o phillip.s.powell@gmail.co.remove-dii-this - 2011-04-27 15:30 +0000
Re: PopupMenuListener eve "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
Re: PopupMenuListener eve phillip.s.powell@gmail.co.remove-dii-this - 2011-04-27 15:30 +0000
Re: PopupMenuListener eve phillip.s.powell@gmail.co.remove-dii-this - 2011-04-27 15:30 +0000
csiph-web