當前位置: 首頁>>代碼示例>>Java>>正文


Java JPopupMenu.setUI方法代碼示例

本文整理匯總了Java中javax.swing.JPopupMenu.setUI方法的典型用法代碼示例。如果您正苦於以下問題:Java JPopupMenu.setUI方法的具體用法?Java JPopupMenu.setUI怎麽用?Java JPopupMenu.setUI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JPopupMenu的用法示例。


在下文中一共展示了JPopupMenu.setUI方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showMenuPopup

import javax.swing.JPopupMenu; //導入方法依賴的package包/類
void showMenuPopup(final JMenu menu) {
    getPopupFactory();
    // if already created then just make it visible
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel view = hackedPopupFactory.containerMap.get(menu);
        view.setVisible(true);
    } else {
        if(!isConfigured(menu)) {
            configureMenu(null, menu);
        }
        final JPopupMenu popup = menu.getPopupMenu();
        
        if(!(popup.getUI() instanceof VisualDesignerPopupMenuUI)) {
            popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
        }
        if (menu.isShowing()) {
            //force popup view creation
            hackedPopupFactory.getPopup(menu, null, 0, 0);
            
            // do later so that the component will definitely be on screen by then
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        popup.show(menu,0,menu.getHeight());
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        //ignore anyexceptions caused by showing the popups
                    }
                    
                }
            });
        }
    }
    this.validate();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:MenuEditLayer.java

示例2: configureMenu

import javax.swing.JPopupMenu; //導入方法依賴的package包/類
void configureMenu(final JComponent parent, final JMenu menu) {
    // make sure it will draw it's border so we can have rollovers and selection
    menu.setBorderPainted(true);
    //install the wrapper icon if not a toplevel JMenu
    if(!isTopLevelMenu(menu)) {
        if(!(menu.getIcon() instanceof WrapperIcon)) {
            menu.setIcon(new WrapperIcon(menu.getIcon()));
        }
    }
    
    // configure the maps and popups
    JPopupMenu popup = menu.getPopupMenu();
    menuPopupUIMap.put(menu, popup.getUI());
    popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
    
    // get all of the components in this menu
    Component[] subComps = menu.getMenuComponents();
    // if this isn't the first time this menu has been opened then the sub components
    // will have been moved to the popupPanel already, so we will find them there instead.
    JPanel popupPanel = getPopupFactory().containerMap.get(menu);
    if(popupPanel != null) {
        subComps = popupPanel.getComponents();
    }
    
    RADVisualContainer menuRAD = (RADVisualContainer) formDesigner.getMetaComponent(menu);
    registerForm(menuRAD,menu);
    
    // recurse for sub-menus
    for(Component c : subComps) {
        if(c instanceof JMenu) {
            configureMenu(menu, (JMenu)c);
            RADComponent rad = formDesigner.getMetaComponent(c);
            registerForm((RADVisualContainer)rad,(JMenu)c);
        } else {
            configureMenuItem(menu, (JComponent) c);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:MenuEditLayer.java


注:本文中的javax.swing.JPopupMenu.setUI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。