Java Code Examples for javax.swing.JPopupMenu#pack()
The following examples show how to use
javax.swing.JPopupMenu#pack() .
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: ButtonPopupSwitcher.java From netbeans with Apache License 2.0 | 6 votes |
private void doSelect(JComponent owner) { invokingComponent = owner; invokingComponent.addMouseListener(this); invokingComponent.addMouseMotionListener(this); pTable.addMouseListener(this); pTable.addMouseMotionListener(this); pTable.getSelectionModel().addListSelectionListener( this ); displayer.getModel().addComplexListDataListener( this ); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); popup = new JPopupMenu(); popup.setBorderPainted( false ); popup.setBorder( BorderFactory.createEmptyBorder() ); popup.add( pTable ); popup.pack(); int locationX = x - (int) pTable.getPreferredSize().getWidth(); int locationY = y + 1; popup.setLocation( locationX, locationY ); popup.setInvoker( invokingComponent ); popup.addPopupMenuListener( this ); popup.setVisible( true ); shown = true; invocationTime = System.currentTimeMillis(); }
Example 2
Source File: ButtonPopupSwitcher.java From netbeans with Apache License 2.0 | 6 votes |
private void doSelect(JComponent owner) { invokingComponent = owner; invokingComponent.addMouseListener(this); invokingComponent.addMouseMotionListener(this); pTable.addMouseListener(this); pTable.addMouseMotionListener(this); pTable.getSelectionModel().addListSelectionListener( this ); controller.getTabModel().addComplexListDataListener( this ); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); popup = new JPopupMenu(); popup.setBorderPainted( false ); popup.setBorder( BorderFactory.createEmptyBorder() ); popup.add( pTable ); popup.pack(); int locationX = x - (int) pTable.getPreferredSize().getWidth(); int locationY = y + 1; popup.setLocation( locationX, locationY ); popup.setInvoker( invokingComponent ); popup.addPopupMenuListener( this ); popup.setVisible( true ); shown = true; invocationTime = System.currentTimeMillis(); }
Example 3
Source File: PhonePad.java From Spark with Apache License 2.0 | 6 votes |
public void showDialpad(Component comp, boolean rightAligned) { menu = new JPopupMenu(); menu.setFocusable(false); menu.add(this); menu.pack(); if (rightAligned) { int width = (int)menu.getPreferredSize().getWidth(); menu.show(comp, -width + comp.getWidth(), comp.getHeight()); } else { menu.show(comp, 0, comp.getHeight()); } this.requestFocus(); }
Example 4
Source File: JPopupMenuUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** Mysterious calls to pack(), invalidate() and validate() ;-) */ private static void refreshPopup(JPopupMenu popup) { popup.pack(); popup.invalidate(); Component c = popup.getParent(); if (c != null) { c.validate(); } }
Example 5
Source File: TasksMenu.java From netbeans with Apache License 2.0 | 5 votes |
void refreshMenu() { JPopupMenu popupMenu = getPopupMenu(); popupMenu.pack(); popupMenu.invalidate(); popupMenu.revalidate(); popupMenu.repaint(); }
Example 6
Source File: JsfPopupAction.java From netbeans with Apache License 2.0 | 5 votes |
/** Gets popup menu. Overrides superclass. Adds lazy menu items creation. */ public JPopupMenu getPopupMenu() { JPopupMenu pm = super.getPopupMenu(); pm.removeAll(); pm.add(new AddNavigationRuleAction()); pm.add(new AddNavigationCaseAction()); pm.add(new JSeparator()); pm.add(new AddManagedBeanAction()); pm.pack(); return pm; }
Example 7
Source File: StrutsPopupAction.java From netbeans with Apache License 2.0 | 5 votes |
/** Gets popup menu. Overrides superclass. Adds lazy menu items creation. */ public JPopupMenu getPopupMenu() { JPopupMenu pm = super.getPopupMenu(); pm.removeAll(); pm.add(new AddActionAction()); pm.add(new AddForwardInlcudeAction()); pm.add(new AddForwardAction()); pm.add(new AddExceptionAction()); pm.add(new JSeparator()); pm.add(new AddFormBeanAction()); pm.add(new AddFormPropertyAction()); pm.pack(); return pm; }
Example 8
Source File: PhonePad.java From Spark with Apache License 2.0 | 5 votes |
public void showDialpad(TelephoneTextField callField) { menu = new JPopupMenu(); menu.setFocusable(false); menu.add(this); menu.pack(); this.callField = callField; menu.show(callField, 0, callField.getHeight()); }
Example 9
Source File: NbCodeFoldingAction.java From netbeans with Apache License 2.0 | 4 votes |
public @Override JPopupMenu getPopupMenu(){ JPopupMenu pm = super.getPopupMenu(); pm.removeAll(); boolean enable = false; BaseKit bKit = getKit(); if (bKit==null) bKit = BaseKit.getKit(NbEditorKit.class); if (bKit!=null){ Action action = bKit.getActionByName(NbEditorKit.generateFoldPopupAction); if (action instanceof BaseAction) { JTextComponent component = NbCodeFoldingAction.getComponent(); MimePath mimePath = component == null ? MimePath.EMPTY : MimePath.parse(DocumentUtilities.getMimeType(component)); Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class); boolean foldingAvailable = prefs.getBoolean(SimpleValueNames.CODE_FOLDING_ENABLE, EditorPreferencesDefaults.defaultCodeFoldingEnable); if (foldingAvailable){ ActionMap contextActionmap = org.openide.util.Utilities.actionsGlobalContext().lookup(ActionMap.class); if (contextActionmap!=null){ foldingAvailable = contextActionmap.get(BaseKit.collapseFoldAction) != null && component != null; if (!foldingAvailable){ bKit = BaseKit.getKit(NbEditorKit.class); if (bKit!=null){ Action defaultAction = bKit.getActionByName(NbEditorKit.generateFoldPopupAction); if (defaultAction instanceof BaseAction) action = defaultAction; } } } } JMenu menu = (JMenu)((BaseAction)action).getPopupMenuItem(foldingAvailable ? component : null); if (menu!=null){ Component comps[] = menu.getMenuComponents(); for (int i=0; i<comps.length; i++){ pm.add(comps[i]); if (comps[i].isEnabled() && !(comps[i] instanceof JSeparator)) { enable = true; } } } } } setEnabled(enable); pm.pack(); return pm; }