javax.swing.JMenu#getPopupMenu ( )源码实例Demo

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

源代码1 项目: dragonwell8_jdk   文件: bug8071705.java
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;
    }
}
 
源代码2 项目: TencentKona-8   文件: bug8071705.java
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;
    }
}
 
源代码3 项目: jdk8u60   文件: bug8071705.java
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;
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: bug8071705.java
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 项目: netbeans   文件: MenuEditLayer.java
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();
}
 
源代码6 项目: netbeans   文件: MenuEditLayer.java
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);
        }
    }
}
 
源代码7 项目: netbeans   文件: MenuEditLayer.java
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);
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: bug8071705.java
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;
    }
}
 
源代码9 项目: openjdk-jdk9   文件: bug8071705.java
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;
    }
}
 
源代码10 项目: jdk8u-jdk   文件: bug8071705.java
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;
    }
}
 
源代码11 项目: hottub   文件: bug8071705.java
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;
    }
}
 
源代码12 项目: jdk8u_jdk   文件: bug8071705.java
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;
    }
}
 
源代码13 项目: jdk8u-jdk   文件: bug8071705.java
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;
    }
}
 
源代码14 项目: jdk8u-dev-jdk   文件: bug8071705.java
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;
    }
}
 
/**
 * 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);
}
 
源代码16 项目: megamek   文件: MenuScroller.java
/**
 * 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);
}