javax.swing.JPopupMenu#pack ( )源码实例Demo

下面列出了javax.swing.JPopupMenu#pack ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ButtonPopupSwitcher.java
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();
}
 
源代码2 项目: netbeans   文件: ButtonPopupSwitcher.java
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();
}
 
源代码3 项目: Spark   文件: PhonePad.java
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();
}
 
源代码4 项目: netbeans   文件: JPopupMenuUtils.java
/** 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();
    }
}
 
源代码5 项目: netbeans   文件: TasksMenu.java
void refreshMenu() {
    JPopupMenu popupMenu = getPopupMenu();
    popupMenu.pack();
    popupMenu.invalidate();
    popupMenu.revalidate();
    popupMenu.repaint();
}
 
源代码6 项目: netbeans   文件: JsfPopupAction.java
/** 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;
}
 
源代码7 项目: netbeans   文件: StrutsPopupAction.java
/** 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;
}
 
源代码8 项目: Spark   文件: PhonePad.java
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());
}
 
源代码9 项目: netbeans   文件: NbCodeFoldingAction.java
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;
}