Java 类javax.swing.event.PopupMenuListener 实例源码
项目:rapidminer
文件:DropDownPopupButton.java
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();
}
}
});
}
项目:rapidminer-studio
文件:DropDownPopupButton.java
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();
}
}
});
}
项目:cn1
文件:JPopupMenuTest.java
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);
}
项目:freeVM
文件:JPopupMenuTest.java
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);
}
项目:freeVM
文件:JPopupMenuTest.java
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);
}
项目:consulo
文件:PopupHandler.java
@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;
}
项目:rapidminer
文件:DropDownPopupButton.java
@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);
}
}
项目:openjdk-jdk10
文件:JPopupMenuOperator.java
/**
* 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);
}
});
}
项目:openjdk-jdk10
文件:JPopupMenuOperator.java
/**
* 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);
}
});
}
项目:openjdk9
文件:JPopupMenuOperator.java
/**
* 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);
}
});
}
项目:openjdk9
文件:JPopupMenuOperator.java
/**
* 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);
}
});
}
项目:j2se_for_android
文件:JComboBox.java
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);
}
}
项目:j2se_for_android
文件:JComboBox.java
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);
}
}
项目:j2se_for_android
文件:JComboBox.java
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);
}
}
项目:j2se_for_android
文件:JPopupMenu.java
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);
}
}
}
项目:j2se_for_android
文件:JPopupMenu.java
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);
}
}
}
项目:j2se_for_android
文件:JPopupMenu.java
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);
}
}
}
项目:javify
文件:JComboBox.java
/**
* 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);
}
项目:javify
文件:JComboBox.java
/**
* 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);
}
项目:javify
文件:JComboBox.java
/**
* 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);
}
项目:javify
文件:JPopupMenu.java
/**
* This method calls popupMenuWillBecomeVisible() of popup menu's
* PopupMenuListeners. This method is invoked just before popup menu
* will appear on the screen.
*/
protected void firePopupMenuWillBecomeVisible()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuWillBecomeVisible(new PopupMenuEvent(this));
}
项目:javify
文件:JPopupMenu.java
/**
* This method calls popupMenuWillBecomeInvisible() of popup
* menu's PopupMenuListeners. This method is invoked just before popup
* menu will disappear from the screen
*/
protected void firePopupMenuWillBecomeInvisible()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuWillBecomeInvisible(new PopupMenuEvent(this));
}
项目:javify
文件:JPopupMenu.java
/**
* This method calls popupMenuCanceled() of popup menu's PopupMenuListeners.
* This method is invoked just before popup menu is cancelled. This happens
* when popup menu is closed without selecting any of its menu items. This
* usually happens when the top-level window is resized or moved.
*/
protected void firePopupMenuCanceled()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuCanceled(new PopupMenuEvent(this));
}
项目:javify
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items will become visible
*/
protected void firePopupMenuWillBecomeVisible()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox));
}
项目:javify
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items will become invisible.
*/
protected void firePopupMenuWillBecomeInvisible()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox));
}
项目:javify
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items was closed without selection.
*/
protected void firePopupMenuCanceled()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuCanceled(new PopupMenuEvent(comboBox));
}
项目:javify
文件:BasicPopupMenuUI.java
/**
* Handles cancel requests (ESC key).
*/
private void cancel()
{
// Fire popup menu cancelled event. Unfortunately the
// firePopupMenuCancelled() is protected in JPopupMenu so we work
// around this limitation by fetching the listeners and notifying them
// directly.
JPopupMenu lastPopup = (JPopupMenu) getLastPopup();
EventListener[] ll = lastPopup.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
{
PopupMenuEvent ev = new PopupMenuEvent(lastPopup);
((PopupMenuListener) ll[i]).popupMenuCanceled(ev);
}
// Close the last popup or the whole selection if there's only one
// popup left.
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement path[] = msm.getSelectedPath();
if(path.length > 4)
{
MenuElement newPath[] = new MenuElement[path.length - 2];
System.arraycopy(path,0,newPath,0,path.length-2);
MenuSelectionManager.defaultManager().setSelectedPath(newPath);
}
else
msm.clearSelectedPath();
}
项目:rapidminer-studio
文件:DropDownPopupButton.java
@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);
}
}
项目:jvm-stm
文件:JComboBox.java
/**
* 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);
}
项目:jvm-stm
文件:JComboBox.java
/**
* 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);
}
项目:jvm-stm
文件:JComboBox.java
/**
* 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);
}
项目:jvm-stm
文件:JPopupMenu.java
/**
* This method calls popupMenuWillBecomeVisible() of popup menu's
* PopupMenuListeners. This method is invoked just before popup menu
* will appear on the screen.
*/
protected void firePopupMenuWillBecomeVisible()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuWillBecomeVisible(new PopupMenuEvent(this));
}
项目:jvm-stm
文件:JPopupMenu.java
/**
* This method calls popupMenuWillBecomeInvisible() of popup
* menu's PopupMenuListeners. This method is invoked just before popup
* menu will disappear from the screen
*/
protected void firePopupMenuWillBecomeInvisible()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuWillBecomeInvisible(new PopupMenuEvent(this));
}
项目:jvm-stm
文件:JPopupMenu.java
/**
* This method calls popupMenuCanceled() of popup menu's PopupMenuListeners.
* This method is invoked just before popup menu is cancelled. This happens
* when popup menu is closed without selecting any of its menu items. This
* usually happens when the top-level window is resized or moved.
*/
protected void firePopupMenuCanceled()
{
EventListener[] ll = listenerList.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
((PopupMenuListener) ll[i]).popupMenuCanceled(new PopupMenuEvent(this));
}
项目:jvm-stm
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items will become visible
*/
protected void firePopupMenuWillBecomeVisible()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox));
}
项目:jvm-stm
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items will become invisible.
*/
protected void firePopupMenuWillBecomeInvisible()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox));
}
项目:jvm-stm
文件:BasicComboPopup.java
/**
* This method fires PopupMenuEvent indicating that combo box's popup list
* of items was closed without selection.
*/
protected void firePopupMenuCanceled()
{
PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
for (int i = 0; i < ll.length; i++)
ll[i].popupMenuCanceled(new PopupMenuEvent(comboBox));
}
项目:jvm-stm
文件:BasicPopupMenuUI.java
/**
* Handles cancel requests (ESC key).
*/
private void cancel()
{
// Fire popup menu cancelled event. Unfortunately the
// firePopupMenuCancelled() is protected in JPopupMenu so we work
// around this limitation by fetching the listeners and notifying them
// directly.
JPopupMenu lastPopup = (JPopupMenu) getLastPopup();
EventListener[] ll = lastPopup.getListeners(PopupMenuListener.class);
for (int i = 0; i < ll.length; i++)
{
PopupMenuEvent ev = new PopupMenuEvent(lastPopup);
((PopupMenuListener) ll[i]).popupMenuCanceled(ev);
}
// Close the last popup or the whole selection if there's only one
// popup left.
MenuSelectionManager msm = MenuSelectionManager.defaultManager();
MenuElement path[] = msm.getSelectedPath();
if(path.length > 4)
{
MenuElement newPath[] = new MenuElement[path.length - 2];
System.arraycopy(path,0,newPath,0,path.length-2);
MenuSelectionManager.defaultManager().setSelectedPath(newPath);
}
else
msm.clearSelectedPath();
}
项目:swingx
文件:BasicDatePickerUI.java
/**
* Returns the PopupMenuListener for the MonthView popup. Lazily created.
*
* @return the popupuMenuListener to install on the popup
*/
protected PopupMenuListener getPopupMenuListener() {
if (popupMenuListener == null) {
popupMenuListener = createPopupMenuListener();
}
return popupMenuListener;
}
项目:cn1
文件:JComboBox.java
public void firePopupMenuWillBecomeVisible() {
PopupMenuEvent event = new PopupMenuEvent(this);
PopupMenuListener[] listeners = getPopupMenuListeners();
for (int i = 0; i < listeners.length; i++) {
listeners[i].popupMenuWillBecomeVisible(event);
}
}