Java Code Examples for javax.swing.event.PopupMenuEvent

The following examples show how to use javax.swing.event.PopupMenuEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Juicebox   Source File: BoundsPopupMenuListener.java    License: MIT License 6 votes vote down vote up
/**
 * Alter the bounds of the popup just before it is made visible.
 */
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    @SuppressWarnings("unchecked")
    JComboBox<E> comboBox = (JComboBox<E>) e.getSource();

    if (comboBox.getItemCount() == 0) return;

    final Object child = comboBox.getAccessibleContext().getAccessibleChild(0);

    if (child instanceof BasicComboPopup) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                customizePopup((BasicComboPopup) child);
            }
        });
    }
}
 
Example 2
Source Project: netbeans   Source File: OutputTab.java    License: Apache License 2.0 6 votes vote down vote up
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    JPopupMenu popup = (JPopupMenu) e.getSource();
    popup.removeAll();
    popup.setInvoker(null);
    // hack
    KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JComponent c = getOutputPane().getTextView();
    c.getInputMap().put(esc, handle);
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(esc, handle);

    //hack end
    popup.removePopupMenuListener(this);
    for (TabAction action : popupItems) {
        action.clearListeners();
    }
}
 
Example 3
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    JComboBox box = (JComboBox) e.getSource();
    Object comp = box.getUI().getAccessibleChild(box, 0);
    if (!(comp instanceof JPopupMenu)) {
        return;
    }
    JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0);
    Dimension size = new Dimension();
    size.width = scrollPane.getPreferredSize().width;
    final int boxItemCount = box.getModel().getSize();
    for (int i = 0; i < boxItemCount; i++) {
        final JLabel label = new JLabel();
        Object elementAt = box.getModel().getElementAt(i);
        if (elementAt != null && elementAt instanceof Product) {
            label.setText(((Product) elementAt).getDisplayName());
        }
        size.width = Math.max(label.getPreferredSize().width, size.width);
    }
    size.height = scrollPane.getPreferredSize().height;
    scrollPane.setPreferredSize(size);
    scrollPane.setMaximumSize(size);
}
 
Example 4
Source Project: darklaf   Source File: DarkScrollableTabSupport.java    License: MIT License 5 votes vote down vote up
public DarkScrollableTabSupport(final DarkTabbedPaneUI ui, final int tabPlacement) {
    super(ui);
    this.ui = ui;
    viewport = new DarkScrollableTabViewport(ui);
    tabPanel = new DarkScrollableTabPanel(ui);

    viewport.setView(tabPanel);
    viewport.addMouseWheelListener(this);

    moreTabsButton = ui.createMoreTabsButton();
    moreTabsButton.setVisible(false);
    moreTabsButton.addActionListener(this);

    newTabButton = ui.createNewTabButton();
    newTabButton.setVisible(PropertyUtil.getBooleanProperty(ui.tabPane, DarkTabbedPaneUI.KEY_SHOW_NEW_TAB_BUTTON));

    scrollPopupMenu = new ScrollPopupMenu(UIManager.getInt(DarkTabbedPaneUI.KEY_MAX_POPUP_HEIGHT));
    PopupMenuListener popupMenuListener = new PopupMenuAdapter() {
        @Override
        public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
            lastClickEvent = System.currentTimeMillis();
        }
    };
    scrollPopupMenu.addPopupMenuListener(popupMenuListener);

    ui.tabPane.add(moreTabsButton);
    timer = new Timer(SCROLL_REWIND_DELAY, e -> endScroll());
    timer.setRepeats(false);
}
 
Example 5
Source Project: chipster   Source File: ClientContextMenu.java    License: MIT License 5 votes vote down vote up
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
	if (selectedItem instanceof DataBean) {
		historyMenuItem.setEnabled(true);
	} else {
		historyMenuItem.setEnabled(false);
	}
}
 
Example 6
Source Project: openjdk-jdk9   Source File: PopupMenuTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    Popup popup = ((PopMenuUIExt) jpopup.getUI()).getPopup();
    if (popup != null) {
        isLightWeight = !popup.getClass().toString().
                contains("HeavyWeightPopup");
    }
}
 
Example 7
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
	popupVisible = false;

	mainButton.getModel().setRollover(false);
	arrowButton.getModel().setSelected(false);
	((JPopupMenu) e.getSource()).removePopupMenuListener(this); // act as good programmer :)
}
 
Example 8
Source Project: wpcleaner   Source File: AbstractPageListPopupListener.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method is called before the popup menu becomes invisible
 * Note that a JPopupMenu can become invisible any time
 * 
 * @param e Event.
 */
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
  if (list != null) {
    list.repaint();
  }
}
 
Example 9
Source Project: netbeans   Source File: InspectAndRefactorPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    if (popup!=null) {
        popup.hide();
        popup = null;
    }
    singleRefactoringCombo.getAccessibleContext().removePropertyChangeListener(listener);
}
 
Example 10
Source Project: netbeans   Source File: QuickSearch.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            dummy.setVisible(false);
        }
    });
}
 
Example 11
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
	popupVisible = false;

	mainButton.getModel().setRollover(false);
	arrowButton.getModel().setSelected(false);
	((JPopupMenu) e.getSource()).removePopupMenuListener(this);
}
 
Example 12
Source Project: weblaf   Source File: PopupMenuAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void popupMenuWillBecomeVisible ( final PopupMenuEvent e )
{
    /**
     * Do nothing by default.
     */
}
 
Example 13
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  EventQueue.invokeLater(() -> {
    JComboBox<?> combo = (JComboBox<?>) e.getSource();
    Accessible a = combo.getAccessibleContext().getAccessibleChild(0);
    // Or Accessible a = combo.getUI().getAccessibleChild(combo, 0);
    if (a instanceof JPopupMenu) {
      JPopupMenu pop = (JPopupMenu) a;
      Point p = new Point(combo.getSize().width, 0);
      SwingUtilities.convertPointToScreen(p, combo);
      pop.setLocation(p);
    }
  });
}
 
Example 14
Source Project: nextreports-designer   Source File: DropDownButton.java    License: Apache License 2.0 5 votes vote down vote up
public void popupMenuWillBecomeInvisible(PopupMenuEvent event) {
	popupVisible = false;

	mainButton.getModel().setRollover(false);
	arrowButton.getModel().setSelected(false);
	((JPopupMenu) event.getSource()).removePopupMenuListener(this);
}
 
Example 15
Source Project: netbeans   Source File: DataComboBoxSupport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
    // without the check the previous non-special item would be displayed
    // while calling DataComboBoxModel.newItemActionPerformed() 
    // instead of NEW_ITEM, but this is unwanted. Same for
    // popupMenuWillBecomeImvisible().
    if (!performingNewItemAction) {
        setPreviousNonSpecialItem((JComboBox)e.getSource());
    }
}
 
Example 16
Source Project: jadx   Source File: JNodeMenuAction.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
	node = getNode();
	setEnabled(node != null);
}
 
Example 17
Source Project: constellation   Source File: RecentFileAction.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuWillBecomeInvisible(final PopupMenuEvent arg0) {
    menu.removeAll();
}
 
Example 18
Source Project: constellation   Source File: RecentFileAction.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuCanceled(final PopupMenuEvent arg0) {
    // Required to implement PopupMenuListener
}
 
Example 19
Source Project: netbeans   Source File: DebugMainProjectAction.java    License: Apache License 2.0 4 votes vote down vote up
@Override public void popupMenuCanceled(PopupMenuEvent e) {
}
 
Example 20
Source Project: Bytecoder   Source File: ServiceDialog.java    License: Apache License 2.0 4 votes vote down vote up
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    changedService = false;
}
 
Example 21
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    changedService = false;
}
 
Example 22
Source Project: netbeans   Source File: FileSelectorField.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
 
Example 23
Source Project: wandora   Source File: TopicMapGraphPanel.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void popupMenuCanceled(PopupMenuEvent e) {}
 
Example 24
Source Project: cstc   Source File: PopupVariableMenu.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void popupMenuCanceled(PopupMenuEvent arg0) {
	// not needed
}
 
Example 25
Source Project: cuba   Source File: SearchAutoCompleteSupport.java    License: Apache License 2.0 4 votes vote down vote up
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    if (doNotClearFilterOnPopupHide) return;

    // the popup menu is being hidden, so clear the filter to return the ComboBoxModel to its unfiltered state
    applyFilter("");
}
 
Example 26
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    if (changedService) {
        changedService = false;
        updatePanels();
    }
}
 
Example 27
Source Project: consulo   Source File: ActionPopupMenuImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
  disposeMenu();
}
 
Example 28
Source Project: ghidra   Source File: SettingsDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
	// stub
}
 
Example 29
Source Project: hottub   Source File: ServiceDialog.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
    if (changedService) {
        changedService = false;
        updatePanels();
    }
}
 
Example 30
Source Project: jdk8u-jdk   Source File: ServiceDialog.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void popupMenuCanceled(PopupMenuEvent e) {
}