本文整理汇总了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);
}
}
}