本文整理匯總了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();
}
示例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);
}
}
}