当前位置: 首页>>代码示例>>Java>>正文


Java PopupMenuListener类代码示例

本文整理汇总了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();
			}
		}
	});
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:DropDownPopupButton.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:JPopupMenuTest.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:PopupHandler.java

示例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);
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:12,代码来源:DropDownPopupButton.java

示例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);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JPopupMenuOperator.java

示例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);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JPopupMenuOperator.java

示例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);
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:10,代码来源:JComboBox.java

示例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);
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:10,代码来源:JComboBox.java

示例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);
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:10,代码来源:JComboBox.java

示例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);
		}
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:13,代码来源:JPopupMenu.java

示例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);
		}
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:13,代码来源:JPopupMenu.java

示例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);
		}
	}
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:12,代码来源:JPopupMenu.java

示例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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:13,代码来源:JComboBox.java

示例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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:14,代码来源:JComboBox.java

示例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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:14,代码来源:JComboBox.java


注:本文中的javax.swing.event.PopupMenuListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。