/** * Returns the current <code>JMenuBar</code> for this <code>Popup</code>, or <code>null</code> if no menu bar has * been set. * * @return the <code>JMenuBar</code> used by this Popup. * @see #setJMenuBar */ public JMenuBar getJMenuBar() { return getRootPane().getJMenuBar(); }
private static void hideMenu(JRootPane rootPane) { JMenuBar menu = rootPane.getJMenuBar(); if (menu != null) { menu.setVisible(false); } } }
private static void hideMenu(JRootPane rootPane) { JMenuBar menu = rootPane.getJMenuBar(); if (menu != null) { menu.setVisible(false); } } }
@Override public Dimension minimumLayoutSize(Container parent) { int contentWidth = 0; int menuWidth = 0; int height = 0; Insets insets = parent.getInsets(); height += insets.top + insets.bottom; JRootPane rootPane = (JRootPane) parent; Dimension contentSize; if (rootPane.getContentPane() != null) { contentSize = rootPane.getContentPane().getMinimumSize(); } else { contentSize = rootPane.getSize(); } contentWidth = contentSize.width; height += contentSize.height; if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) { Dimension menuSize = rootPane.getJMenuBar().getMinimumSize(); height += menuSize.height; menuWidth = menuSize.width; } return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height); }
@Override public Dimension minimumLayoutSize(Container parent) { int contentWidth = 0; int menuWidth = 0; int height = 0; Insets insets = parent.getInsets(); height += insets.top + insets.bottom; JRootPane rootPane = (JRootPane) parent; Dimension contentSize; if (rootPane.getContentPane() != null) { contentSize = rootPane.getContentPane().getMinimumSize(); } else { contentSize = rootPane.getSize(); } contentWidth = contentSize.width; height += contentSize.height; if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) { Dimension menuSize = rootPane.getJMenuBar().getMinimumSize(); height += menuSize.height; menuWidth = menuSize.width; } return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height); }
@Override public Dimension preferredLayoutSize(Container parent) { int contentWidth = 0; int menuWidth = 0; int height = 0; JRootPane rootPane = (JRootPane) parent; // hideMenu(rootPane); Insets insets = parent.getInsets(); height += insets.top + insets.bottom; Dimension contentSize; if (rootPane.getContentPane() != null) { contentSize = rootPane.getContentPane().getPreferredSize(); } else { contentSize = rootPane.getSize(); } contentWidth = contentSize.width; height += contentSize.height; if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) { Dimension menuSize = rootPane.getJMenuBar().getPreferredSize(); height += menuSize.height; menuWidth = menuSize.width; } return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height); }
@Override public Dimension preferredLayoutSize(Container parent) { int contentWidth = 0; int menuWidth = 0; int height = 0; JRootPane rootPane = (JRootPane) parent; hideMenu(rootPane); Insets insets = parent.getInsets(); height += insets.top + insets.bottom; Dimension contentSize; if (rootPane.getContentPane() != null) { contentSize = rootPane.getContentPane().getPreferredSize(); } else { contentSize = rootPane.getSize(); } contentWidth = contentSize.width; height += contentSize.height; if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) { Dimension menuSize = rootPane.getJMenuBar().getPreferredSize(); height += menuSize.height; menuWidth = menuSize.width; } return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height); }
private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated final JRootPane panel = getDesktopPane().getRootPane(); if (savedMenuBar == null) savedMenuBar = panel.getJMenuBar(); if (menuBar != null) panel.setJMenuBar(menuBar); }//GEN-LAST:event_formInternalFrameActivated
public int getJMenuBarExtraHeight() { JMenuBar jMenuBar = getRootPane().getJMenuBar(); if (jMenuBar != null && jMenuBar.isVisible()) return jMenuBar.getHeight(); return 0; }
@Override public void run() { JMenuBar burpJMenuBar = rootPane.getJMenuBar(); autoRepeaterJMenu = new JMenu("AutoRepeater");
protected boolean isToolBarUnderMenubar() { if (toolBar != null && toolBar.getOrientation() == JToolBar.HORIZONTAL) { JRootPane rp = SwingUtilities.getRootPane(toolBar); JMenuBar mb = rp.getJMenuBar(); if (mb != null) { Point mbPoint = new Point(0, 0); mbPoint = SwingUtilities.convertPoint(mb, mbPoint, rp); Point tbPoint = new Point(0, 0); tbPoint = SwingUtilities.convertPoint(toolBar, tbPoint, rp); tbPoint.y -= mb.getHeight() - 1; Rectangle rect = new Rectangle(mbPoint, mb.getSize()); return rect.contains(tbPoint); } } return false; }
private Rectangle calculateBounds(Component overlayComponent) { JRootPane rootPane = SwingUtilities.getRootPane(overlayComponent); Rectangle rect = SwingUtilities.convertRectangle(overlayComponent.getParent(), overlayComponent.getBounds(), rootPane.getContentPane()); JMenuBar menuBar = rootPane.getJMenuBar(); rect.x += MARGIN; rect.y += MARGIN + (menuBar == null ? 0 : menuBar.getHeight()); rect.width -= MARGIN * 2; rect.height -= MARGIN * 2; return rect; }
@Override public void extensionUnloaded() { // unregister menu JMenuBar burpMenuBar = rootPane.getJMenuBar(); BurpExtender.getCallbacks().printOutput("Unregistering menu"); burpMenuBar.remove(autoRepeaterJMenu); burpMenuBar.repaint(); }
/** * Returns the maximum amount of space the layout can use. * * @param target the Container for which this layout manager * is being used * @return a Dimension object containing the layout's maximum size */ public Dimension maximumLayoutSize(Container target) { Dimension rd, mbd; Insets i = rootPane.getInsets(); Container contentPane = rootPane.getContentPane(); JMenuBar menuBar = rootPane.getJMenuBar(); if (menuBar != null && menuBar.isVisible()) { mbd = menuBar.getMaximumSize(); } else { mbd = new Dimension(0, 0); } if (contentPane != null && contentPane.isVisible()) { rd = contentPane.getMaximumSize(); } else { // This is silly, but should stop an overflow error rd = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE - i.top - i.bottom - mbd.height - 1); } return new Dimension(Math.min(rd.width, mbd.width) + i.left + i.right, rd.height + mbd.height + i.top + i.bottom); }
@Override protected void peerPaint(Graphics g, boolean update) { if (shouldDecorate() || getSwingComponent().getJMenuBar() != null) { /* * Don't paint the whole area, we only need to paint the frame * borders */ JComponent c = getSwingComponent(); if (c != null) { Insets insets = getInsets(); Area clip = new Area(c.getBounds()); Rectangle clip2 = new Rectangle(insets.left, insets.top, c.getWidth() - insets.left - insets.right, c.getHeight() - insets.bottom - insets.top); clip.subtract(new Area(clip2)); Graphics peerG = new WindowClippedGraphics((Graphics2D) g, clip); try { c.paint(peerG); } finally { peerG.dispose(); } } } }
/** * Returns the minimum amount of space the layout needs. * * @param parent the Container for which this layout manager * is being used * @return a Dimension object containing the layout's minimum size */ public Dimension minimumLayoutSize(Container parent) { Dimension rd, mbd; Insets i = rootPane.getInsets(); Container contentPane = rootPane.getContentPane(); JMenuBar menuBar = rootPane.getJMenuBar(); if (contentPane != null && contentPane.isVisible()) { rd = contentPane.getMinimumSize(); } else if (contentPane != null) { rd = new Dimension(0, contentPane.getPreferredSize().height); } else { rd = new Dimension(0,0); } if (menuBar != null && menuBar.isVisible()) { mbd = menuBar.getMinimumSize(); } else { mbd = new Dimension(0, 0); } return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right, rd.height + mbd.height + i.top + i.bottom); }
/** * Returns the amount of space the layout would like to have. * * @param parent the Container for which this layout manager * is being used * @return a Dimension object containing the layout's preferred size */ @Override public Dimension preferredLayoutSize(Container parent) { Dimension rd, mbd; Insets i = rootPane.getInsets(); Container contentPane = rootPane.getContentPane(); JMenuBar menuBar = rootPane.getJMenuBar(); if (contentPane.isVisible()) { rd = contentPane.getPreferredSize(); } else { rd = new Dimension(0, contentPane.getPreferredSize().height); } if (menuBar != null && menuBar.isVisible()) { mbd = menuBar.getPreferredSize(); } else { mbd = new Dimension(0, 0); } return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right, rd.height + mbd.height + i.top + i.bottom); }
void altReleased(KeyEvent ev) { if(menuCanceledOnPress) { return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if(msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; if(menu != null) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } } }
Component glassPane = rootPane.getGlassPane(); Container contentPane = rootPane.getContentPane(); JMenuBar menuBar = rootPane.getJMenuBar();
void altPressed(KeyEvent ev) { MenuSelectionManager msm = MenuSelectionManager.defaultManager(); MenuElement[] path = msm.getSelectedPath(); if(path.length > 0 && ! (path[0] instanceof ComboPopup)) { msm.clearSelectedPath(); menuCanceledOnPress = true; ev.consume(); } else if(path.length > 0) { // We are in ComboBox menuCanceledOnPress = false; ev.consume(); } else { menuCanceledOnPress = false; JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; if(menu != null) { ev.consume(); } } }