Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #962
| From | phillip.s.powell@gmail.co.remove-dii-this |
|---|---|
| Subject | PopupMenuListener event o |
| Message-ID | <1171656855.396238.100790@v33g2000cwv.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:30 +0000 |
| Organization | TDS.net |
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