Java Code Examples for javax.swing.event.PopupMenuEvent#getSource()
The following examples show how to use
javax.swing.event.PopupMenuEvent#getSource() .
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 File: OutputTab.java From netbeans with Apache License 2.0 | 6 votes |
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 2
Source File: BoundsPopupMenuListener.java From Juicebox with MIT License | 6 votes |
/** * 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 3
Source File: SourceProductSelector.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@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 File: BoundsPopupMenuListener.java From openAGV with Apache License 2.0 | 5 votes |
/** * Alter the bounds of the popup just before it is made visible. * * @param e The event. */ @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox<?> comboBox = (JComboBox) e.getSource(); if (comboBox.getItemCount() == 0) { return; } final Object child = comboBox.getAccessibleContext().getAccessibleChild(0); if (child instanceof BasicComboPopup) { SwingUtilities.invokeLater(() -> customizePopup((BasicComboPopup) child)); } }
Example 5
Source File: DebugMainProjectAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { if (!menuInitialized) { JPopupMenu menu = (JPopupMenu)e.getSource(); debugHistorySupport.init(menu); attachHistorySupport.init(menu); menuInitialized = true; } else { debugHistorySupport.refreshItems(); } }
Example 6
Source File: SearchAutoCompleteSupport.java From cuba with Apache License 2.0 | 5 votes |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // if the combo box does not contain a prototype display value, skip our sizing logic final Object prototypeValue = comboBox.getPrototypeDisplayValue(); if (prototypeValue == null) return; final JComponent popupComponent = (JComponent) e.getSource(); // attempt to extract the JScrollPane that scrolls the popup if (popupComponent.getComponent(0) instanceof JScrollPane) { final JScrollPane scroller = (JScrollPane) popupComponent.getComponent(0); // fetch the existing preferred size of the scroller, and we'll check if it is large enough final Dimension scrollerSize = scroller.getPreferredSize(); // calculates the preferred size of the renderer's component for the prototype value final Dimension prototypeSize = getPrototypeSize(prototypeValue); // add to the preferred width, the width of the vertical scrollbar, when it is visible prototypeSize.width += scroller.getVerticalScrollBar().getPreferredSize().width; // adjust the preferred width of the scroller, if necessary if (prototypeSize.width > scrollerSize.width) { scrollerSize.width = prototypeSize.width; // set the new size of the scroller scroller.setMaximumSize(scrollerSize); scroller.setPreferredSize(scrollerSize); scroller.setMinimumSize(scrollerSize); } } }
Example 7
Source File: DropDownPopupButton.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@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); } }
Example 8
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox<?> combo = (JComboBox<?>) e.getSource(); Dimension size = combo.getSize(); if (size.width >= POPUP_MIN_WIDTH) { return; } if (!adjusting) { adjusting = true; combo.setSize(POPUP_MIN_WIDTH, size.height); combo.showPopup(); } combo.setSize(size); adjusting = false; }
Example 9
Source File: ConfigurationsComboModel.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox combo = (JComboBox) e.getSource(); confirm(new EventObject(combo.getEditor().getEditorComponent())); combo.removePopupMenuListener(this); }
Example 10
Source File: ConfigurationsComboModel.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox combo = (JComboBox) e.getSource(); confirm(new EventObject(combo.getEditor().getEditorComponent())); combo.removePopupMenuListener(this); }
Example 11
Source File: ConfigurationsComboModel.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox combo = (JComboBox) e.getSource(); confirm(new EventObject(combo.getEditor().getEditorComponent())); combo.removePopupMenuListener(this); }
Example 12
Source File: ConfigurationsComboModel.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox combo = (JComboBox) e.getSource(); confirm(new EventObject(combo.getEditor().getEditorComponent())); combo.removePopupMenuListener(this); }
Example 13
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox<?> c = (JComboBox<?>) e.getSource(); c.setSelectedItem(c.getEditor().getItem()); }
Example 14
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox<?> c = (JComboBox<?>) e.getSource(); c.setSelectedItem(c.getEditor().getItem()); }
Example 15
Source File: AquaLnFPopupLocationFix.java From cropplanning with GNU General Public License v3.0 | 4 votes |
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { final JComponent popupComponent = (JComponent) e.getSource(); fixPopupLocation(popupComponent); }