本文整理汇总了Java中javax.swing.JMenu.getPopupMenu方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.getPopupMenu方法的具体用法?Java JMenu.getPopupMenu怎么用?Java JMenu.getPopupMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.getPopupMenu方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showMenuPopup
import javax.swing.JMenu; //导入方法依赖的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: unconfigureMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
private void unconfigureMenu(final JMenu menu) {
if (hackedPopupFactory == null) return; // Issue 145981
// restore the UI
menu.getPopupMenu().setUI(menuPopupUIMap.get(menu));
// restore all children
JPanel popup = hackedPopupFactory.containerMap.get(menu);
if(popup != null) {
for(Component c : popup.getComponents()) {
if(c instanceof JMenu) {
unconfigureMenu((JMenu)c);
} else {
unconfigureMenuItem((JComponent) c);
}
}
//hide the popup(s) if it's still visible
if(menu.getPopupMenu() != null) {
menu.getPopupMenu().setVisible(false);
}
popup.setVisible(false);
//layers.remove(popup);
}
VisualDesignerJPanelPopup pop = hackedPopupFactory.getPopup(menu);
if(pop != null) {
pop.hide();
}
if(popup != null) {
popup.setVisible(false);
}
menu.setPopupMenuVisible(false);
hackedPopupFactory.containerMap.remove(menu);
}
示例3: configureMenu
import javax.swing.JMenu; //导入方法依赖的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);
}
}
}
示例4: runActualTest
import javax.swing.JMenu; //导入方法依赖的package包/类
private static void runActualTest(GraphicsDevice device,
CountDownLatch latch,
JFrame frame,
boolean [] result)
{
Rectangle screenBounds = setLocation(frame, device);
JMenu menu = frame.getJMenuBar().getMenu(0);
menu.doClick();
Point location = menu.getLocationOnScreen();
JPopupMenu pm = menu.getPopupMenu();
Dimension pmSize = pm.getSize();
int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY");
int height = location.y + yOffset + pmSize.height + menu.getHeight();
int available = screenBounds.y + screenBounds.height - height;
if (available > 0) {
Point origin = pm.getLocationOnScreen();
if (origin.y < location.y) {
// growing upward, wrong!
result[0] = false;
} else {
// growing downward, ok!
result[0] = true;
}
} else {
// there is no space, growing upward would be ok, so we pass
result[0] = true;
}
}
示例5: MenuScroller
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Constructs a <code>MenuScroller</code> that scrolls a menu with the
* specified number of items to display in the scrolling region, the
* specified scrolling interval, and the specified numbers of items fixed at
* the top and bottom of the menu.
*
* @param menu the menu
* @param scrollCount the number of items to display in the scrolling portion
* @param interval the scroll interval, in milliseconds
* @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
* @throws IllegalArgumentException if scrollCount or interval is 0 or
* negative or if topFixedCount or bottomFixedCount is negative
*/
public MenuScroller(JMenu menu, int scrollCount, int interval,
int topFixedCount, int bottomFixedCount) {
this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount);
}
示例6: MenuScroller
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Constructs a <code>MenuScroller</code> that scrolls a menu with the
* specified number of items to display in the scrolling region, the
* specified scrolling interval, and the specified numbers of items fixed at
* the top and bottom of the menu.
*
* @param menu the menu
* @param scrollCount the number of items to display in the scrolling portion
* @param interval the scroll interval, in milliseconds
* @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be 0
* @throws IllegalArgumentException if scrollCount or interval is 0 or
* negative or if topFixedCount or bottomFixedCount is negative
*/
public MenuScroller(JMenu menu, int scrollCount, int interval,
int topFixedCount, int bottomFixedCount) {
this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount);
}
示例7: MenuScroller
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Constructs a <code>MenuScroller</code> that scrolls a menu with the
* specified number of items to display in the scrolling region, the
* specified scrolling interval, and the specified numbers of items fixed at
* the top and bottom of the menu.
*
* @param menu the menu
* @param scrollCount the number of items to display in the scrolling
* portion
* @param interval the scroll interval, in milliseconds
* @param topFixedCount the number of items to fix at the top. May be 0
* @param bottomFixedCount the number of items to fix at the bottom. May be
* 0
* @throws IllegalArgumentException if scrollCount or interval is 0 or
* negative or if topFixedCount or bottomFixedCount is negative
*/
public MenuScroller(JMenu menu, int scrollCount, int interval,
int topFixedCount, int bottomFixedCount) {
this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount);
}