本文整理汇总了Java中javax.swing.event.PopupMenuListener类的典型用法代码示例。如果您正苦于以下问题:Java PopupMenuListener类的具体用法?Java PopupMenuListener怎么用?Java PopupMenuListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PopupMenuListener类属于javax.swing.event包,在下文中一共展示了PopupMenuListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupAction
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
private void setupAction() {
addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
JPopupMenu popupMenu = menuProvider.getPopupMenu();
if (!popupMenu.isVisible()) {
// hack to prevent filter popup from opening itself again
// when you click the button to actually close it while it
// is open
if (System.currentTimeMillis() - lastPopupCloseTime < 250) {
return;
}
popupMenu.addPopupMenuListener(popupListener);
for (PopupMenuListener listener : otherListeners) {
popupMenu.addPopupMenuListener(listener);
}
popupMenu.show(DropDownPopupButton.this, 0, DropDownPopupButton.this.getHeight() - 1);
popupMenu.requestFocusInWindow();
}
}
});
}
示例2: testAddGetRemovePopupMenuListener
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
public void testAddGetRemovePopupMenuListener() {
PopupMenuListener listener1 = new ConcretePopupMenuListener();
PopupMenuListener listener2 = new ConcretePopupMenuListener();
PopupMenuListener listener3 = new ConcretePopupMenuListener();
EventListener[] listenersArray = null;
listenersArray = popup.getPopupMenuListeners();
int initialValue = listenersArray.length;
popup.addPopupMenuListener(listener1);
popup.addPopupMenuListener(listener2);
popup.addPopupMenuListener(listener2);
listenersArray = popup.getPopupMenuListeners();
assertEquals(initialValue + 3, listenersArray.length);
popup.removePopupMenuListener(listener1);
popup.addPopupMenuListener(listener3);
popup.addPopupMenuListener(listener3);
listenersArray = popup.getPopupMenuListeners();
assertEquals(initialValue + 4, listenersArray.length);
popup.removePopupMenuListener(listener3);
popup.removePopupMenuListener(listener3);
listenersArray = popup.getPopupMenuListeners();
assertEquals(initialValue + 2, listenersArray.length);
popup.removePopupMenuListener(listener2);
popup.removePopupMenuListener(listener2);
listenersArray = popup.getPopupMenuListeners();
assertEquals(initialValue, listenersArray.length);
}
示例3: installPopupHandler
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
@Nonnull
public static MouseListener installPopupHandler(@Nonnull JComponent component,
@Nonnull ActionGroup group,
String place,
@Nonnull ActionManager actionManager,
@Nullable PopupMenuListener menuListener) {
if (ApplicationManager.getApplication() == null) return new MouseAdapter(){};
PopupHandler popupHandler = new PopupHandler() {
public void invokePopup(Component comp, int x, int y) {
ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(place, group);
popupMenu.setTargetComponent(component);
JPopupMenu menu = popupMenu.getComponent();
if (menuListener != null) menu.addPopupMenuListener(menuListener);
menu.show(comp, x, y);
}
};
component.addMouseListener(popupHandler);
return popupHandler;
}
示例4: popupMenuWillBecomeInvisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
@Override
public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
lastPopupCloseTime = System.currentTimeMillis();
JPopupMenu jPopupMenu = (JPopupMenu) e.getSource();
jPopupMenu.removePopupMenuListener(this);
for (PopupMenuListener otherListener : otherListeners) {
jPopupMenu.removePopupMenuListener(otherListener);
}
}
示例5: addPopupMenuListener
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
/**
* Maps {@code JPopupMenu.addPopupMenuListener(PopupMenuListener)}
* through queue
*/
public void addPopupMenuListener(final PopupMenuListener popupMenuListener) {
runMapping(new MapVoidAction("addPopupMenuListener") {
@Override
public void map() {
((JPopupMenu) getSource()).addPopupMenuListener(popupMenuListener);
}
});
}
示例6: removePopupMenuListener
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
/**
* Maps {@code JPopupMenu.removePopupMenuListener(PopupMenuListener)}
* through queue
*/
public void removePopupMenuListener(final PopupMenuListener popupMenuListener) {
runMapping(new MapVoidAction("removePopupMenuListener") {
@Override
public void map() {
((JPopupMenu) getSource()).removePopupMenuListener(popupMenuListener);
}
});
}
示例7: firePopupMenuWillBecomeVisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
public void firePopupMenuWillBecomeVisible() {
PopupMenuListener[] listeners = list.getListeners(PopupMenuListener.class);
PopupMenuEvent e = null;
for (int i = listeners.length - 1; i >= 0; i--) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i]).popupMenuWillBecomeVisible(e);
}
}
示例8: firePopupMenuWillBecomeInvisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
public void firePopupMenuWillBecomeInvisible() {
PopupMenuListener[] listeners = list.getListeners(PopupMenuListener.class);
PopupMenuEvent e = null;
for (int i = listeners.length - 1; i >= 0; i--) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i]).popupMenuWillBecomeInvisible(e);
}
}
示例9: firePopupMenuCanceled
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
public void firePopupMenuCanceled() {
PopupMenuListener[] listeners = list.getListeners(PopupMenuListener.class);
PopupMenuEvent e = null;
for (int i = listeners.length - 1; i >= 0; i--) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i]).popupMenuCanceled(e);
}
}
示例10: firePopupMenuWillBecomeVisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
protected void firePopupMenuWillBecomeVisible() {
Object[] listeners = list.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1])
.popupMenuWillBecomeVisible(e);
}
}
}
示例11: firePopupMenuWillBecomeInvisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
protected void firePopupMenuWillBecomeInvisible() {
Object[] listeners = list.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1])
.popupMenuWillBecomeInvisible(e);
}
}
}
示例12: firePopupMenuCanceled
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
protected void firePopupMenuCanceled() {
Object[] listeners = list.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1]).popupMenuCanceled(e);
}
}
}
示例13: firePopupMenuCanceled
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
/**
* Fires a popupMenuCanceled() event to all <code>PopupMenuListeners</code>.
*
* Note: This method is intended for use by plaf classes only.
*/
public void firePopupMenuCanceled()
{
PopupMenuListener[] listeners = getPopupMenuListeners();
PopupMenuEvent e = new PopupMenuEvent(this);
for (int i = 0; i < listeners.length; i++)
listeners[i].popupMenuCanceled(e);
}
示例14: firePopupMenuWillBecomeInvisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
/**
* Fires a popupMenuWillBecomeInvisible() event to all
* <code>PopupMenuListeners</code>.
*
* Note: This method is intended for use by plaf classes only.
*/
public void firePopupMenuWillBecomeInvisible()
{
PopupMenuListener[] listeners = getPopupMenuListeners();
PopupMenuEvent e = new PopupMenuEvent(this);
for (int i = 0; i < listeners.length; i++)
listeners[i].popupMenuWillBecomeInvisible(e);
}
示例15: firePopupMenuWillBecomeVisible
import javax.swing.event.PopupMenuListener; //导入依赖的package包/类
/**
* Fires a popupMenuWillBecomeVisible() event to all
* <code>PopupMenuListeners</code>.
*
* Note: This method is intended for use by plaf classes only.
*/
public void firePopupMenuWillBecomeVisible()
{
PopupMenuListener[] listeners = getPopupMenuListeners();
PopupMenuEvent e = new PopupMenuEvent(this);
for (int i = 0; i < listeners.length; i++)
listeners[i].popupMenuWillBecomeVisible(e);
}