0001: /*
0002: * @(#)VsnetMenuItemUI.java
0003: *
0004: * Copyright 2002 JIDE Software Inc. All rights reserved.
0005: */
0006:
0007: package com.jidesoft.plaf.eclipse;
0008:
0009: import com.jidesoft.icons.IconsFactory;
0010: import com.jidesoft.plaf.UIDefaultsLookup;
0011: import com.jidesoft.plaf.basic.ThemePainter;
0012: import com.jidesoft.swing.JideSwingUtilities;
0013: import com.jidesoft.swing.TopLevelMenuContainer;
0014: import com.sun.java.swing.plaf.windows.WindowsGraphicsUtils;
0015: import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
0016:
0017: import javax.swing.*;
0018: import javax.swing.event.*;
0019: import javax.swing.plaf.*;
0020: import javax.swing.plaf.basic.BasicHTML;
0021: import javax.swing.text.View;
0022: import java.awt.*;
0023: import java.awt.event.ActionEvent;
0024: import java.awt.event.InputEvent;
0025: import java.awt.event.KeyEvent;
0026: import java.awt.event.MouseEvent;
0027: import java.awt.geom.AffineTransform;
0028: import java.beans.PropertyChangeEvent;
0029: import java.beans.PropertyChangeListener;
0030:
0031: /**
0032: * MenuItem UI implementation
0033: */
0034: public class EclipseMenuItemUI extends MenuItemUI {
0035: protected JMenuItem menuItem = null;
0036: protected Color selectionBackground;
0037: protected Color selectionForeground;
0038: protected Color disabledForeground;
0039: protected Color acceleratorForeground;
0040: protected Color acceleratorSelectionForeground;
0041: private String acceleratorDelimiter;
0042:
0043: protected int defaultTextIconGap;
0044: protected Font acceleratorFont;
0045:
0046: protected MouseInputListener mouseInputListener;
0047: protected MenuDragMouseListener menuDragMouseListener;
0048: protected MenuKeyListener menuKeyListener;
0049: private PropertyChangeListener propertyChangeListener;
0050:
0051: protected Icon arrowIcon = null;
0052: protected Icon checkIcon = null;
0053:
0054: protected boolean oldBorderPainted;
0055:
0056: /**
0057: * Used for accelerator binding, lazily created.
0058: */
0059: InputMap windowInputMap;
0060:
0061: private static final boolean DEBUG = false; // show bad params, misc.
0062:
0063: // added for VsnetMenuItemUI
0064: protected Color shadowColor;
0065: protected int defaultAccelEndGap;
0066: protected int defaultShadowWidth;
0067: private Color borderColor;
0068: private Color backgroundColor;
0069: // end added for VsnetMenuItemUI
0070:
0071: /* Client Property keys for text and accelerator text widths */
0072: static final String MAX_TEXT_WIDTH = "maxTextWidth";
0073: static final String MAX_ACC_WIDTH = "maxAccWidth";
0074:
0075: protected ThemePainter _painter;
0076:
0077: public static ComponentUI createUI(JComponent c) {
0078: return new EclipseMenuItemUI();
0079: }
0080:
0081: @Override
0082: public void installUI(JComponent c) {
0083: menuItem = (JMenuItem) c;
0084:
0085: installDefaults();
0086: installComponents(menuItem);
0087: installListeners();
0088: installKeyboardActions();
0089: }
0090:
0091: protected void installDefaults() {
0092: _painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
0093: String prefix = getPropertyPrefix();
0094:
0095: acceleratorFont = UIDefaultsLookup
0096: .getFont("MenuItem.acceleratorFont");
0097:
0098: menuItem.setOpaque(true);
0099: if (menuItem.getMargin() == null
0100: || (menuItem.getMargin() instanceof UIResource)) {
0101: // if(useCheckAndArrow())
0102: // menuItem.setMargin(UIManagerLookup.getInsets("MenuItem.margin"));
0103: // else
0104: menuItem.setMargin(UIDefaultsLookup.getInsets(prefix
0105: + ".margin"));
0106: }
0107:
0108: // added for VsnetMenuItemUI
0109: defaultTextIconGap = UIDefaultsLookup
0110: .getInt("MenuItem.textIconGap");
0111: defaultAccelEndGap = UIDefaultsLookup
0112: .getInt("MenuItem.accelEndGap");
0113: defaultShadowWidth = UIDefaultsLookup
0114: .getInt("MenuItem.shadowWidth");
0115: // end add
0116:
0117: borderColor = UIDefaultsLookup
0118: .getColor("MenuItem.selectionBorderColor");
0119: backgroundColor = UIDefaultsLookup
0120: .getColor("MenuItem.background");
0121: shadowColor = UIDefaultsLookup.getColor("MenuItem.shadowColor");
0122:
0123: LookAndFeel.installBorder(menuItem, prefix + ".border");
0124: oldBorderPainted = menuItem.isBorderPainted();
0125: Object value = UIDefaultsLookup.get(prefix + ".borderPainted");
0126: menuItem
0127: .setBorderPainted(value instanceof Boolean ? (Boolean) value
0128: : false);
0129: LookAndFeel.installColorsAndFont(menuItem, prefix
0130: + ".background", prefix + ".foreground", prefix
0131: + ".font");
0132:
0133: // MenuItem specific defaults
0134: if (selectionBackground == null
0135: || selectionBackground instanceof UIResource) {
0136: selectionBackground = UIDefaultsLookup.getColor(prefix
0137: + ".selectionBackground");
0138: }
0139: if (selectionForeground == null
0140: || selectionForeground instanceof UIResource) {
0141: selectionForeground = UIDefaultsLookup.getColor(prefix
0142: + ".selectionForeground");
0143: }
0144: if (disabledForeground == null
0145: || disabledForeground instanceof UIResource) {
0146: disabledForeground = UIDefaultsLookup.getColor(prefix
0147: + ".disabledForeground");
0148: }
0149: if (acceleratorForeground == null
0150: || acceleratorForeground instanceof UIResource) {
0151: acceleratorForeground = UIDefaultsLookup.getColor(prefix
0152: + ".acceleratorForeground");
0153: }
0154: if (acceleratorSelectionForeground == null
0155: || acceleratorSelectionForeground instanceof UIResource) {
0156: acceleratorSelectionForeground = UIDefaultsLookup
0157: .getColor(prefix
0158: + ".acceleratorSelectionForeground");
0159: }
0160: // Get accelerator delimiter
0161: acceleratorDelimiter = UIDefaultsLookup
0162: .getString("MenuItem.acceleratorDelimiter");
0163: if (acceleratorDelimiter == null) {
0164: acceleratorDelimiter = "+";
0165: }
0166: // Icons
0167: if (arrowIcon == null || arrowIcon instanceof UIResource) {
0168: arrowIcon = UIDefaultsLookup.getIcon(prefix + ".arrowIcon");
0169: }
0170: if (checkIcon == null || checkIcon instanceof UIResource) {
0171: checkIcon = UIDefaultsLookup.getIcon(prefix + ".checkIcon");
0172: }
0173: }
0174:
0175: /**
0176: * @since 1.3
0177: */
0178: protected void installComponents(JMenuItem menuItem) {
0179: BasicHTML.updateRenderer(menuItem, menuItem.getText());
0180: }
0181:
0182: protected String getPropertyPrefix() {
0183: return "MenuItem";
0184: }
0185:
0186: protected void installListeners() {
0187: if ((mouseInputListener = createMouseInputListener(menuItem)) != null) {
0188: menuItem.addMouseListener(mouseInputListener);
0189: menuItem.addMouseMotionListener(mouseInputListener);
0190: }
0191: if ((menuDragMouseListener = createMenuDragMouseListener(menuItem)) != null) {
0192: menuItem.addMenuDragMouseListener(menuDragMouseListener);
0193: }
0194: if ((menuKeyListener = createMenuKeyListener(menuItem)) != null) {
0195: menuItem.addMenuKeyListener(menuKeyListener);
0196: }
0197: if ((propertyChangeListener = createPropertyChangeListener(menuItem)) != null) {
0198: menuItem.addPropertyChangeListener(propertyChangeListener);
0199: }
0200: }
0201:
0202: protected void installKeyboardActions() {
0203: ActionMap actionMap = getActionMap();
0204:
0205: SwingUtilities.replaceUIActionMap(menuItem, actionMap);
0206: updateAcceleratorBinding();
0207: }
0208:
0209: @Override
0210: public void uninstallUI(JComponent c) {
0211: menuItem = (JMenuItem) c;
0212: uninstallDefaults();
0213: uninstallComponents(menuItem);
0214: uninstallListeners();
0215: uninstallKeyboardActions();
0216:
0217: //Remove the textWidth and accWidth values from the parent's Client Properties.
0218: Container parent = menuItem.getParent();
0219: if ((parent != null && parent instanceof JComponent)
0220: && !(menuItem instanceof JMenu && ((JMenu) menuItem)
0221: .isTopLevelMenu())) {
0222: JComponent p = (JComponent) parent;
0223: p.putClientProperty(EclipseMenuItemUI.MAX_ACC_WIDTH, null);
0224: p.putClientProperty(EclipseMenuItemUI.MAX_TEXT_WIDTH, null);
0225: }
0226:
0227: menuItem = null;
0228: }
0229:
0230: protected void uninstallDefaults() {
0231: _painter = null;
0232: LookAndFeel.uninstallBorder(menuItem);
0233: menuItem.setBorderPainted(oldBorderPainted);
0234: if (menuItem.getMargin() instanceof UIResource)
0235: menuItem.setMargin(null);
0236: if (arrowIcon instanceof UIResource)
0237: arrowIcon = null;
0238: if (checkIcon instanceof UIResource)
0239: checkIcon = null;
0240: }
0241:
0242: /**
0243: * @since 1.3
0244: */
0245: protected void uninstallComponents(JMenuItem menuItem) {
0246: BasicHTML.updateRenderer(menuItem, "");
0247: }
0248:
0249: protected void uninstallListeners() {
0250: if (mouseInputListener != null) {
0251: menuItem.removeMouseListener(mouseInputListener);
0252: menuItem.removeMouseMotionListener(mouseInputListener);
0253: }
0254: if (menuDragMouseListener != null) {
0255: menuItem.removeMenuDragMouseListener(menuDragMouseListener);
0256: }
0257: if (menuKeyListener != null) {
0258: menuItem.removeMenuKeyListener(menuKeyListener);
0259: }
0260: if (propertyChangeListener != null) {
0261: menuItem
0262: .removePropertyChangeListener(propertyChangeListener);
0263: }
0264:
0265: mouseInputListener = null;
0266: menuDragMouseListener = null;
0267: menuKeyListener = null;
0268: propertyChangeListener = null;
0269: }
0270:
0271: protected void uninstallKeyboardActions() {
0272: SwingUtilities.replaceUIActionMap(menuItem, null);
0273: if (windowInputMap != null) {
0274: SwingUtilities.replaceUIInputMap(menuItem,
0275: JComponent.WHEN_IN_FOCUSED_WINDOW, null);
0276: windowInputMap = null;
0277: }
0278: }
0279:
0280: protected MouseInputListener createMouseInputListener(JComponent c) {
0281: return new MouseInputHandler();
0282: }
0283:
0284: protected MenuDragMouseListener createMenuDragMouseListener(
0285: JComponent c) {
0286: return new MenuDragMouseHandler();
0287: }
0288:
0289: protected MenuKeyListener createMenuKeyListener(JComponent c) {
0290: return new MenuKeyHandler();
0291: }
0292:
0293: private PropertyChangeListener createPropertyChangeListener(
0294: JComponent c) {
0295: return new PropertyChangeHandler();
0296: }
0297:
0298: ActionMap getActionMap() {
0299: String propertyPrefix = getPropertyPrefix();
0300: String uiKey = propertyPrefix + ".actionMap";
0301: ActionMap am = (ActionMap) UIDefaultsLookup.get(uiKey);
0302: if (am == null) {
0303: am = createActionMap();
0304: UIManager.getLookAndFeelDefaults().put(uiKey, am);
0305: }
0306: return am;
0307: }
0308:
0309: ActionMap createActionMap() {
0310: ActionMap map = new ActionMapUIResource();
0311: map.put("doClick", new ClickAction());
0312:
0313: // removed for VsnetMenuItem. it's protected method
0314: // Set the ActionMap's parent to the Auditory Feedback Action Map
0315: // BasicLookAndFeel lf = (BasicLookAndFeel) UIManager.getLookAndFeel();
0316: // ActionMap audioMap = lf.getAudioActionMap();
0317: // map.setParent(audioMap);
0318:
0319: return map;
0320: }
0321:
0322: InputMap createInputMap(int condition) {
0323: if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
0324: return new ComponentInputMapUIResource(menuItem);
0325: }
0326: return null;
0327: }
0328:
0329: void updateAcceleratorBinding() {
0330: KeyStroke accelerator = menuItem.getAccelerator();
0331:
0332: if (windowInputMap != null) {
0333: windowInputMap.clear();
0334: }
0335: if (accelerator != null) {
0336: if (windowInputMap == null) {
0337: windowInputMap = createInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
0338: SwingUtilities.replaceUIInputMap(menuItem,
0339: JComponent.WHEN_IN_FOCUSED_WINDOW,
0340: windowInputMap);
0341: }
0342: windowInputMap.put(accelerator, "doClick");
0343: }
0344: }
0345:
0346: @Override
0347: public Dimension getMinimumSize(JComponent c) {
0348: Dimension d = null;
0349: View v = (View) c.getClientProperty(BasicHTML.propertyKey);
0350: if (v != null) {
0351: d = getPreferredSize(c);
0352: d.width -= v.getPreferredSpan(View.X_AXIS)
0353: - v.getMinimumSpan(View.X_AXIS);
0354: }
0355: return d;
0356: }
0357:
0358: @Override
0359: public Dimension getPreferredSize(JComponent c) {
0360: return getPreferredMenuItemSize(c, checkIcon, arrowIcon,
0361: defaultTextIconGap);
0362: }
0363:
0364: @Override
0365: public Dimension getMaximumSize(JComponent c) {
0366: Dimension d = null;
0367: View v = (View) c.getClientProperty(BasicHTML.propertyKey);
0368: if (v != null) {
0369: d = getPreferredSize(c);
0370: d.width += v.getMaximumSpan(View.X_AXIS)
0371: - v.getPreferredSpan(View.X_AXIS);
0372: }
0373: return d;
0374: }
0375:
0376: // these rects are used for painting and preferredsize calculations.
0377: // they used to be regenerated constantly. Now they are reused.
0378: static Rectangle zeroRect = new Rectangle(0, 0, 0, 0);
0379: static Rectangle iconRect = new Rectangle();
0380: static Rectangle textRect = new Rectangle();
0381: static Rectangle acceleratorRect = new Rectangle();
0382: static Rectangle checkIconRect = new Rectangle();
0383: static Rectangle arrowIconRect = new Rectangle();
0384: static Rectangle viewRect = new Rectangle(Short.MAX_VALUE,
0385: Short.MAX_VALUE);
0386: static Rectangle r = new Rectangle();
0387:
0388: private void resetRects() {
0389: iconRect.setBounds(zeroRect);
0390: textRect.setBounds(zeroRect);
0391: acceleratorRect.setBounds(zeroRect);
0392: checkIconRect.setBounds(zeroRect);
0393: arrowIconRect.setBounds(zeroRect);
0394: viewRect.setBounds(0, 0, Short.MAX_VALUE, Short.MAX_VALUE);
0395: r.setBounds(zeroRect);
0396: }
0397:
0398: protected Dimension getPreferredMenuItemSize(JComponent c,
0399: Icon checkIcon, Icon arrowIcon, int textIconGap) {
0400: JMenuItem b = (JMenuItem) c;
0401: Icon icon = b.getIcon();
0402: String text = b.getText();
0403: KeyStroke accelerator = b.getAccelerator();
0404: String acceleratorText = "";
0405:
0406: if (accelerator != null) {
0407: int modifiers = accelerator.getModifiers();
0408: if (modifiers > 0) {
0409: acceleratorText = KeyEvent
0410: .getKeyModifiersText(modifiers);
0411: //acceleratorText += "-";
0412: acceleratorText += acceleratorDelimiter;
0413: }
0414: int keyCode = accelerator.getKeyCode();
0415: if (keyCode != 0) {
0416: acceleratorText += KeyEvent.getKeyText(keyCode);
0417: } else {
0418: acceleratorText += accelerator.getKeyChar();
0419: }
0420: }
0421:
0422: Font font = b.getFont();
0423: FontMetrics fm = b.getFontMetrics(font);
0424: FontMetrics fmAccel = b.getFontMetrics(acceleratorFont);
0425:
0426: resetRects();
0427:
0428: layoutMenuItem(fm, text, fmAccel, acceleratorText, icon,
0429: checkIcon, arrowIcon, b.getVerticalAlignment(), b
0430: .getHorizontalAlignment(), b
0431: .getVerticalTextPosition(), b
0432: .getHorizontalTextPosition(), viewRect,
0433: iconRect, textRect, acceleratorRect, checkIconRect,
0434: arrowIconRect, text == null ? 0 : textIconGap,
0435: defaultAccelEndGap);
0436: // find the union of the icon and text rects
0437: r.setBounds(textRect);
0438: if (!iconRect.isEmpty()) {
0439: r = SwingUtilities.computeUnion(iconRect.x, iconRect.y,
0440: iconRect.width, iconRect.height, r);
0441: }
0442: // To make the accelerator texts appear in a column, find the widest MenuItem text
0443: // and the widest accelerator text.
0444:
0445: //Get the parent, which stores the information.
0446: Container parent = menuItem.getParent();
0447:
0448: //Check the parent, and see that it is not a top-level menu.
0449: if (parent != null
0450: && parent instanceof JComponent
0451: && !(menuItem instanceof JMenu && ((JMenu) menuItem)
0452: .isTopLevelMenu())) {
0453: JComponent p = (JComponent) parent;
0454:
0455: //Get widest text so far from parent, if no one exists null is returned.
0456: Integer maxTextWidth = (Integer) p
0457: .getClientProperty(EclipseMenuItemUI.MAX_TEXT_WIDTH);
0458: Integer maxAccWidth = (Integer) p
0459: .getClientProperty(EclipseMenuItemUI.MAX_ACC_WIDTH);
0460:
0461: int maxTextValue = maxTextWidth != null ? maxTextWidth : 0;
0462: int maxAccValue = maxAccWidth != null ? maxAccWidth : 0;
0463:
0464: //Compare the text widths, and adjust the r.width to the widest.
0465: if (r.width < maxTextValue) {
0466: r.width = maxTextValue;
0467: } else {
0468: p.putClientProperty(EclipseMenuItemUI.MAX_TEXT_WIDTH,
0469: r.width);
0470: }
0471:
0472: //Compare the accelarator widths.
0473: if (acceleratorRect.width > maxAccValue) {
0474: maxAccValue = acceleratorRect.width;
0475: p.putClientProperty(EclipseMenuItemUI.MAX_ACC_WIDTH,
0476: acceleratorRect.width);
0477: }
0478:
0479: //Add on the widest accelerator
0480: r.width += maxAccValue;
0481: r.width += textIconGap;
0482: r.width += defaultAccelEndGap;
0483: }
0484:
0485: if (icon != null)
0486: r.width += textIconGap;
0487:
0488: Insets insets = b.getInsets();
0489: if (useCheckAndArrow()) {
0490: insets = UIDefaultsLookup.getInsets("MenuItem.margin");
0491: r.width += 5;
0492: }
0493: if (insets != null) {
0494: r.width += insets.left + insets.right;
0495: r.height += insets.top + insets.bottom;
0496: }
0497:
0498: // if the width is even, bump it up one. This is critical
0499: // for the focus dash line to draw properly
0500: if (r.width % 2 == 0) {
0501: r.width++;
0502: }
0503:
0504: // if the height is even, bump it up one. This is critical
0505: // for the text to center properly
0506: if (r.height % 2 == 0) {
0507: r.height++;
0508: }
0509:
0510: if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL) {
0511: return r.getSize();
0512: } else {
0513: return new Dimension(r.height, r.width);
0514: }
0515: }
0516:
0517: /**
0518: * We draw the background in paintMenuItem()
0519: * so override update (which fills the background of opaque
0520: * components by default) to just call paint().
0521: */
0522: @Override
0523: public void update(Graphics g, JComponent c) {
0524: paint(g, c);
0525: }
0526:
0527: @Override
0528: public void paint(Graphics g, JComponent c) {
0529: paintMenuItem(g, c, checkIcon, arrowIcon, selectionBackground,
0530: selectionForeground, defaultTextIconGap);
0531: }
0532:
0533: protected void paintMenuItem(Graphics g, JComponent c,
0534: Icon checkIcon, Icon arrowIcon, Color background,
0535: Color foreground, int defaultTextIconGap) {
0536: JMenuItem b = (JMenuItem) c;
0537: ButtonModel model = b.getModel();
0538:
0539: int menuWidth = 0;
0540: int menuHeight = 0;
0541:
0542: if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL) {
0543: // Dimension size = b.getSize();
0544: menuWidth = b.getWidth();
0545: menuHeight = b.getHeight();
0546: } else {
0547: // Dimension size = b.getSize();
0548: menuWidth = b.getHeight();
0549: menuHeight = b.getWidth();
0550: Graphics2D g2d = (Graphics2D) g;
0551: AffineTransform oldAt = g2d.getTransform();
0552: g2d.rotate(Math.PI / 2);
0553: g2d.translate(0, -menuHeight + 1);
0554: }
0555:
0556: Insets i = c.getInsets();
0557:
0558: resetRects();
0559:
0560: viewRect.setBounds(0, 0, menuWidth, menuHeight);
0561:
0562: viewRect.x += i.left;
0563: viewRect.y += i.top;
0564: viewRect.width -= (i.right + viewRect.x);
0565: viewRect.height -= (i.bottom + viewRect.y);
0566:
0567: Font holdf = g.getFont();
0568: Font f = c.getFont();
0569: g.setFont(f);
0570: FontMetrics fm = g.getFontMetrics(f);
0571: FontMetrics fmAccel = g.getFontMetrics(acceleratorFont);
0572:
0573: // get Accelerator text
0574: KeyStroke accelerator = b.getAccelerator();
0575: String acceleratorText = "";
0576: if (accelerator != null) {
0577: int modifiers = accelerator.getModifiers();
0578: if (modifiers > 0) {
0579: acceleratorText = KeyEvent
0580: .getKeyModifiersText(modifiers);
0581: //acceleratorText += "-";
0582: acceleratorText += acceleratorDelimiter;
0583: }
0584:
0585: int keyCode = accelerator.getKeyCode();
0586: if (keyCode != 0) {
0587: acceleratorText += KeyEvent.getKeyText(keyCode);
0588: } else {
0589: acceleratorText += accelerator.getKeyChar();
0590: }
0591: }
0592:
0593: // layout the text and icon
0594: String text = layoutMenuItem(fm, b.getText(), fmAccel,
0595: acceleratorText, b.getIcon(), checkIcon, arrowIcon, b
0596: .getVerticalAlignment(), b
0597: .getHorizontalAlignment(), b
0598: .getVerticalTextPosition(), b
0599: .getHorizontalTextPosition(), viewRect,
0600: iconRect, textRect, acceleratorRect, checkIconRect,
0601: arrowIconRect, b.getText() == null ? 0
0602: : defaultTextIconGap, defaultTextIconGap);
0603:
0604: // Paint background
0605: paintBackground(g, b, background);
0606:
0607: Color holdc = g.getColor();
0608:
0609: // Paint the Check
0610: if ((c.getUIClassID().indexOf("CheckBoxMenu") >= 0 || c
0611: .getUIClassID().indexOf("RadioButtonMenu") >= 0)
0612: && checkIcon != null) {
0613: paintCheckBox(b, g, checkIcon);
0614: g.setColor(holdc);
0615: }
0616:
0617: paintIcon(b, g);
0618:
0619: // Draw the Text
0620: if (text != null) {
0621: View v = (View) c.getClientProperty(BasicHTML.propertyKey);
0622: if (v != null) {
0623: v.paint(g, textRect);
0624: } else {
0625: paintText(g, b, textRect, text);
0626: }
0627: }
0628:
0629: // Draw the Accelerator Text
0630: if (acceleratorText != null && !acceleratorText.equals("")) {
0631:
0632: //Get the maxAccWidth from the parent to calculate the offset.
0633: int accOffset = 0;
0634: Container parent = menuItem.getParent();
0635: if (parent != null && parent instanceof JComponent) {
0636: JComponent p = (JComponent) parent;
0637: Integer maxValueInt = (Integer) p
0638: .getClientProperty(EclipseMenuItemUI.MAX_ACC_WIDTH);
0639: int maxValue = maxValueInt != null ? maxValueInt
0640: : acceleratorRect.width;
0641:
0642: //Calculate the offset, with which the accelerator texts will be drawn with.
0643: accOffset = maxValue - acceleratorRect.width;
0644: }
0645:
0646: g.setFont(acceleratorFont);
0647: if (!model.isEnabled()) {
0648: // *** paint the acceleratorText disabled
0649: if (disabledForeground != null) {
0650: g.setColor(disabledForeground);
0651: JideSwingUtilities.drawString(menuItem, g,
0652: acceleratorText, acceleratorRect.x
0653: - accOffset, acceleratorRect.y
0654: + fmAccel.getAscent());
0655: } else {
0656: g.setColor(b.getBackground().brighter());
0657: JideSwingUtilities.drawString(menuItem, g,
0658: acceleratorText, acceleratorRect.x
0659: - accOffset, acceleratorRect.y
0660: + fmAccel.getAscent());
0661: g.setColor(b.getBackground().darker());
0662: JideSwingUtilities.drawString(menuItem, g,
0663: acceleratorText, acceleratorRect.x
0664: - accOffset - 1, acceleratorRect.y
0665: + fmAccel.getAscent() - 1);
0666: }
0667: } else {
0668: // *** paint the acceleratorText normally
0669: if (model.isArmed()
0670: || (c instanceof JMenu && model.isSelected())) {
0671: g.setColor(acceleratorSelectionForeground);
0672: } else {
0673: g.setColor(acceleratorForeground);
0674: }
0675: JideSwingUtilities.drawString(menuItem, g,
0676: acceleratorText, acceleratorRect.x - accOffset,
0677: acceleratorRect.y + fmAccel.getAscent());
0678: }
0679: }
0680:
0681: // Paint the Arrow
0682: if (arrowIcon != null) {
0683: if (model.isArmed()
0684: || (c instanceof JMenu && model.isSelected()))
0685: g.setColor(foreground);
0686: if (useCheckAndArrow())
0687: arrowIcon.paintIcon(c, g, arrowIconRect.x,
0688: arrowIconRect.y);
0689: }
0690: g.setColor(holdc);
0691: g.setFont(holdf);
0692: }
0693:
0694: private void paintCheckBox(JMenuItem b, Graphics g, Icon checkIcon) {
0695: boolean selected = false;
0696: ButtonModel model = b.getModel();
0697: if (b instanceof JCheckBoxMenuItem)
0698: selected = ((JCheckBoxMenuItem) b).isSelected();
0699: else if (b instanceof JRadioButtonMenuItem)
0700: selected = ((JRadioButtonMenuItem) b).isSelected();
0701: if (selected) {
0702: if (b.getIcon() == null) {
0703: if (model.isArmed()
0704: || (b instanceof JMenu && model.isSelected())) {
0705: if (checkIcon instanceof ImageIcon) {
0706: ImageIcon image = IconsFactory.createMaskImage(
0707: b, checkIcon, Color.BLACK,
0708: selectionForeground);
0709: image.paintIcon(b, g, checkIconRect.x,
0710: checkIconRect.y);
0711: } else {
0712: ImageIcon image = IconsFactory
0713: .createNegativeImage(b, checkIcon);
0714: image.paintIcon(b, g, checkIconRect.x,
0715: checkIconRect.y);
0716: }
0717: } else {
0718: if (checkIcon instanceof ImageIcon) {
0719: ImageIcon image = IconsFactory.createMaskImage(
0720: b, checkIcon, Color.BLACK, b
0721: .getForeground());
0722: image.paintIcon(b, g, checkIconRect.x,
0723: checkIconRect.y);
0724: } else {
0725: checkIcon.paintIcon(b, g, checkIconRect.x,
0726: checkIconRect.y);
0727: }
0728: }
0729: }
0730: }
0731: }
0732:
0733: private void paintIcon(JMenuItem b, Graphics g) {
0734: ButtonModel model = b.getModel();
0735: // Paint the Icon
0736: if (b.getIcon() != null) {
0737: Icon icon;
0738: if (!model.isEnabled()) {
0739: icon = b.getDisabledIcon();
0740: if (icon == null) {
0741: icon = b.getIcon();
0742: if (icon instanceof ImageIcon) {
0743: icon = IconsFactory
0744: .createGrayImage(((ImageIcon) icon)
0745: .getImage());
0746: } else {
0747: icon = IconsFactory.createGrayImage(b, icon);
0748: }
0749: }
0750: } else if (model.isPressed() && model.isArmed()) {
0751: icon = b.getPressedIcon();
0752: if (icon == null) {
0753: // Use default icon
0754: icon = b.getIcon();
0755: }
0756: } else {
0757: icon = b.getIcon();
0758: }
0759:
0760: if (icon != null) {
0761: icon.paintIcon(b, g, iconRect.x, iconRect.y);
0762: }
0763: }
0764: }
0765:
0766: /**
0767: * Draws the background of the menu item.
0768: *
0769: * @param g the paint graphics
0770: * @param menuItem menu item to be painted
0771: * @param bgColor selection background color
0772: * @since 1.4
0773: */
0774: protected void paintBackground(Graphics g, JMenuItem menuItem,
0775: Color bgColor) {
0776: ButtonModel model = menuItem.getModel();
0777: Color oldColor = g.getColor();
0778: int menuWidth = menuItem.getWidth();
0779: int menuHeight = menuItem.getHeight();
0780:
0781: if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL) {
0782: menuWidth = menuItem.getWidth();
0783: menuHeight = menuItem.getHeight();
0784: } else {
0785: menuWidth = menuItem.getHeight();
0786: menuHeight = menuItem.getWidth();
0787: }
0788:
0789: if (menuItem.isOpaque()) {
0790: if (menuItem.getBackground() instanceof UIResource) {
0791: g.setColor(backgroundColor);
0792: } else {
0793: g.setColor(menuItem.getBackground());
0794: }
0795: g.fillRect(0, 0, menuWidth, menuHeight);
0796:
0797: if (model.isArmed()
0798: || (menuItem instanceof JMenu && model.isSelected())) {
0799: g.setColor(bgColor);
0800: g.fillRect(1, 1, menuWidth - 2, menuHeight - 2);
0801: }
0802: g.setColor(oldColor);
0803: }
0804: }
0805:
0806: /**
0807: * Method which renders the text of the current menu item.
0808: * <p/>
0809: *
0810: * @param g Graphics context
0811: * @param menuItem Current menu item to render
0812: * @param textRect Bounding rectangle to render the text.
0813: * @param text String to render
0814: */
0815: protected void paintText(Graphics g, JMenuItem menuItem,
0816: Rectangle textRect, String text) {
0817: // Note: This method is almost identical to the same method in WindowsMenuUI
0818: ButtonModel model = menuItem.getModel();
0819:
0820: if (!model.isEnabled()) {
0821: // *** paint the text disabled
0822: WindowsGraphicsUtils.paintText(g, menuItem, textRect, text,
0823: 0);
0824: } else {
0825: FontMetrics fm = g.getFontMetrics();
0826: int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
0827: // W2K Feature: Check to see if the Underscore should be rendered.
0828: if (WindowsLookAndFeel.isMnemonicHidden() == true) {
0829: mnemonicIndex = -1;
0830: }
0831:
0832: Color oldColor = g.getColor();
0833:
0834: // *** paint the text normally
0835: if (model.isArmed()
0836: || (menuItem instanceof JMenu && model.isSelected())) {
0837: g.setColor(selectionForeground); // Uses protected field.
0838: }
0839: JideSwingUtilities.drawStringUnderlineCharAt(menuItem, g,
0840: text, mnemonicIndex, textRect.x, textRect.y
0841: + fm.getAscent());
0842: g.setColor(oldColor);
0843: }
0844: }
0845:
0846: /**
0847: * Compute and return the location of the icons origin, the
0848: * location of origin of the text baseline, and a possibly clipped
0849: * version of the compound labels string. Locations are computed
0850: * relative to the viewRect rectangle.
0851: */
0852:
0853: private String layoutMenuItem(FontMetrics fm, String text,
0854: FontMetrics fmAccel, String acceleratorText, Icon icon,
0855: Icon checkIcon, Icon arrowIcon, int verticalAlignment,
0856: int horizontalAlignment, int verticalTextPosition,
0857: int horizontalTextPosition, Rectangle viewRect,
0858: Rectangle iconRect, Rectangle textRect,
0859: Rectangle acceleratorRect, Rectangle checkIconRect,
0860: Rectangle arrowIconRect, int textIconGap, int menuItemGap) {
0861:
0862: SwingUtilities.layoutCompoundLabel(menuItem, fm, text, icon,
0863: verticalAlignment, horizontalAlignment,
0864: verticalTextPosition, horizontalTextPosition, viewRect,
0865: iconRect, textRect, textIconGap);
0866:
0867: // get viewRect which is the bounds of menuitem
0868: viewRect.x = viewRect.y = 0;
0869: if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL) {
0870: // Dimension size = b.getSize();
0871: viewRect.height = menuItem.getHeight();
0872: viewRect.width = menuItem.getWidth();
0873: } else {
0874: // Dimension size = b.getSize();
0875: viewRect.height = menuItem.getWidth();
0876: viewRect.width = menuItem.getHeight();
0877: }
0878:
0879: /* Initialize the acceelratorText bounds rectangle textRect. If a null
0880: * or and empty String was specified we substitute "" here
0881: * and use 0,0,0,0 for acceleratorTextRect.
0882: */
0883: if ((acceleratorText == null) || acceleratorText.equals("")) {
0884: acceleratorRect.width = acceleratorRect.height = 0;
0885: acceleratorText = "";
0886: } else {
0887: acceleratorRect.width = SwingUtilities.computeStringWidth(
0888: fmAccel, acceleratorText);
0889: acceleratorRect.height = fmAccel.getHeight();
0890: }
0891:
0892: if ((text == null) || text.equals("")) {
0893: textRect.width = textRect.height = 0;
0894: text = "";
0895: } else {
0896: boolean textIsEmpty = (text == null) || text.equals("");
0897: int lsb = 0;
0898:
0899: View v = null;
0900: v = (menuItem != null) ? (View) menuItem
0901: .getClientProperty("html") : null;
0902: if (v != null) {
0903: textRect.width = (int) v.getPreferredSpan(View.X_AXIS);
0904: textRect.height = (int) v.getPreferredSpan(View.Y_AXIS);
0905: } else {
0906: textRect.width = SwingUtilities.computeStringWidth(fm,
0907: text);
0908: textRect.height = fm.getHeight();
0909: }
0910: }
0911:
0912: if (icon == null) {
0913: if (useCheckAndArrow())
0914: iconRect.width = iconRect.height = 16;
0915: else
0916: iconRect.width = iconRect.height = 0;
0917: } else {
0918: iconRect.width = icon.getIconWidth();
0919: iconRect.height = icon.getIconHeight();
0920: }
0921:
0922: if (arrowIcon == null) {
0923: arrowIconRect.width = arrowIconRect.height = 0;
0924: } else {
0925: arrowIconRect.width = arrowIcon.getIconWidth();
0926: arrowIconRect.height = arrowIcon.getIconHeight();
0927: }
0928:
0929: if (checkIcon == null) {
0930: checkIconRect.width = checkIconRect.height = 0;
0931: } else {
0932: checkIconRect.width = checkIcon.getIconWidth();
0933: checkIconRect.height = checkIcon.getIconHeight();
0934: }
0935:
0936: if (menuItem.getComponentOrientation().isLeftToRight()) {
0937: // left a shadow for non-top level menu
0938: if (useCheckAndArrow()) {
0939: iconRect.x = (defaultShadowWidth - iconRect.width) >> 1;
0940: textRect.x = defaultShadowWidth + textIconGap;
0941: } else {
0942: if (icon != null) {
0943: iconRect.x = menuItem.getInsets().left;
0944: textRect.x = iconRect.x + iconRect.width
0945: + textIconGap;
0946: } else {
0947: textRect.x = menuItem.getInsets().left;
0948: }
0949: }
0950:
0951: // Position the Accelerator text rect
0952: acceleratorRect.x = viewRect.x + viewRect.width
0953: - defaultAccelEndGap - acceleratorRect.width;
0954: // // Position the Check and Arrow Icons
0955: if (useCheckAndArrow()) {
0956: checkIconRect.x = (defaultShadowWidth - checkIconRect.width) >> 1;
0957: arrowIconRect.x = viewRect.x + viewRect.width
0958: - menuItemGap - arrowIconRect.width;
0959: }
0960: } else {
0961: // isLeftToRight is false
0962: }
0963:
0964: if (verticalTextPosition == SwingConstants.CENTER) {
0965: // put it in the middle
0966: textRect.y = ((viewRect.height - textRect.height) >> 1) + 1;
0967: iconRect.y = ((viewRect.height - iconRect.height) >> 1) + 1;
0968: }
0969:
0970: Rectangle labelRect = iconRect.union(textRect);
0971:
0972: // Align the accelertor text and the check and arrow icons vertically
0973: // with the center of the label rect.
0974: acceleratorRect.y = labelRect.y + (labelRect.height >> 1)
0975: - (acceleratorRect.height >> 1);
0976:
0977: if (useCheckAndArrow()) {
0978: arrowIconRect.y = ((viewRect.height - arrowIconRect.height) >> 1) + 1;//
0979: checkIconRect.y = ((viewRect.height - checkIconRect.height) >> 1) + 1;//labelRect.y + (labelRect.height / 2) - (checkIconRect.height / 2);
0980: }
0981: //
0982: /*
0983: System.out.println("Layout: text=" + menuItem.getText() + "\n\tv="
0984: + viewRect + "\n\tc=" + checkIconRect + "\n\ti="
0985: + iconRect + "\n\tt=" + textRect + "\n\tacc="
0986: + acceleratorRect + "\n\ta=" + arrowIconRect + "\n");
0987: */
0988:
0989: return text;
0990: }
0991:
0992: /*
0993: * Returns false if the component is a JMenu and it is a top
0994: * level menu (on the menubar).
0995: */
0996: private boolean useCheckAndArrow() {
0997: boolean b = true;
0998: if ((menuItem instanceof JMenu)
0999: && (((JMenu) menuItem).isTopLevelMenu())) {
1000: b = false;
1001: }
1002: return b;
1003: }
1004:
1005: public MenuElement[] getPath() {
1006: MenuSelectionManager m = MenuSelectionManager.defaultManager();
1007: MenuElement oldPath[] = m.getSelectedPath();
1008: MenuElement newPath[];
1009: int i = oldPath.length;
1010: if (i == 0)
1011: return new MenuElement[0];
1012: Component parent = menuItem.getParent();
1013: if (oldPath[i - 1].getComponent() == parent) {
1014: // The parent popup menu is the last so far
1015: newPath = new MenuElement[i + 1];
1016: System.arraycopy(oldPath, 0, newPath, 0, i);
1017: newPath[i] = menuItem;
1018: } else {
1019: // A sibling menuitem is the current selection
1020: //
1021: // This probably needs to handle 'exit submenu into
1022: // a menu item. Search backwards along the current
1023: // selection until you find the parent popup menu,
1024: // then copy up to that and add yourself...
1025: int j;
1026: for (j = oldPath.length - 1; j >= 0; j--) {
1027: if (oldPath[j].getComponent() == parent)
1028: break;
1029: }
1030: newPath = new MenuElement[j + 2];
1031: System.arraycopy(oldPath, 0, newPath, 0, j + 1);
1032: newPath[j + 1] = menuItem;
1033: /*
1034: System.out.println("Sibling condition -- ");
1035: System.out.println("Old array : ");
1036: printMenuElementArray(oldPath, false);
1037: System.out.println("New array : ");
1038: printMenuElementArray(newPath, false);
1039: */
1040: }
1041: return newPath;
1042: }
1043:
1044: /*
1045: void printMenuElementArray(MenuElement path[], boolean dumpStack) {
1046: System.out.println("Path is(");
1047: int i, j;
1048: for (i = 0, j = path.length; i < j; i++) {
1049: for (int k = 0; k <= i; k++)
1050: System.out.print(" ");
1051: MenuElement me = (MenuElement) path[i];
1052: if (me instanceof JMenuItem)
1053: System.out.println(((JMenuItem) me).getText() + ", ");
1054: else if (me == null)
1055: System.out.println("NULL , ");
1056: else
1057: System.out.println("" + me + ", ");
1058: }
1059: System.out.println(")");
1060:
1061: if (dumpStack == true)
1062: Thread.dumpStack();
1063: }
1064:
1065: */
1066:
1067: protected class MouseInputHandler implements MouseInputListener {
1068: public void mouseClicked(MouseEvent e) {
1069: }
1070:
1071: public void mousePressed(MouseEvent e) {
1072: }
1073:
1074: public void mouseReleased(MouseEvent e) {
1075: MenuSelectionManager manager = MenuSelectionManager
1076: .defaultManager();
1077: Point p = e.getPoint();
1078: if (p.x >= 0 && p.x < menuItem.getWidth() && p.y >= 0
1079: && p.y < menuItem.getHeight()) {
1080: doClick(manager);
1081: } else {
1082: manager.processMouseEvent(e);
1083: }
1084: }
1085:
1086: public void mouseEntered(MouseEvent e) {
1087: MenuSelectionManager manager = MenuSelectionManager
1088: .defaultManager();
1089: int modifiers = e.getModifiers();
1090: // 4188027: drag enter/exit added in JDK 1.1.7A, JDK1.2
1091: if ((modifiers & (InputEvent.BUTTON1_MASK
1092: | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK)) != 0) {
1093: MenuSelectionManager.defaultManager()
1094: .processMouseEvent(e);
1095: } else {
1096: manager.setSelectedPath(getPath());
1097: }
1098: }
1099:
1100: public void mouseExited(MouseEvent e) {
1101: MenuSelectionManager manager = MenuSelectionManager
1102: .defaultManager();
1103:
1104: int modifiers = e.getModifiers();
1105: // 4188027: drag enter/exit added in JDK 1.1.7A, JDK1.2
1106: if ((modifiers & (InputEvent.BUTTON1_MASK
1107: | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK)) != 0) {
1108: MenuSelectionManager.defaultManager()
1109: .processMouseEvent(e);
1110: } else {
1111:
1112: MenuElement path[] = manager.getSelectedPath();
1113: if (path.length > 1) {
1114: MenuElement newPath[] = new MenuElement[path.length - 1];
1115: int i, c;
1116: for (i = 0, c = path.length - 1; i < c; i++)
1117: newPath[i] = path[i];
1118: manager.setSelectedPath(newPath);
1119: }
1120: }
1121: }
1122:
1123: public void mouseDragged(MouseEvent e) {
1124: MenuSelectionManager.defaultManager().processMouseEvent(e);
1125: }
1126:
1127: public void mouseMoved(MouseEvent e) {
1128: }
1129: }
1130:
1131: private class MenuDragMouseHandler implements MenuDragMouseListener {
1132: public void menuDragMouseEntered(MenuDragMouseEvent e) {
1133: }
1134:
1135: public void menuDragMouseDragged(MenuDragMouseEvent e) {
1136: MenuSelectionManager manager = e.getMenuSelectionManager();
1137: MenuElement path[] = e.getPath();
1138: manager.setSelectedPath(path);
1139: }
1140:
1141: public void menuDragMouseExited(MenuDragMouseEvent e) {
1142: }
1143:
1144: public void menuDragMouseReleased(MenuDragMouseEvent e) {
1145: MenuSelectionManager manager = e.getMenuSelectionManager();
1146: Point p = e.getPoint();
1147: if (p.x >= 0 && p.x < menuItem.getWidth() && p.y >= 0
1148: && p.y < menuItem.getHeight()) {
1149: doClick(manager);
1150: } else {
1151: manager.clearSelectedPath();
1152: }
1153: }
1154: }
1155:
1156: private class MenuKeyHandler implements MenuKeyListener {
1157:
1158: /**
1159: * Handles the mnemonic key typed in the MenuItem if this menuItem is in
1160: * a standalone popup menu. This invocation normally
1161: * handled in BasicMenuUI.MenuKeyHandler.menuKeyPressed. Ideally, the
1162: * MenuKeyHandlers for both BasicMenuItemUI and BasicMenuUI can be consolidated
1163: * into BasicPopupMenuUI but that would require an semantic change. This
1164: * would result in a performance win since we can shortcut a lot of the needless
1165: * processing from MenuSelectionManager.processKeyEvent(). See 4670831.
1166: */
1167: public void menuKeyTyped(MenuKeyEvent e) {
1168: if (DEBUG) {
1169: System.out
1170: .println("in EclipseMenuItemUI.menuKeyTyped for "
1171: + menuItem.getText());
1172: }
1173: int key = menuItem.getMnemonic();
1174: if (key == 0 || e.getPath().length != 2) // Hack! Only proceed if in a JPopupMenu
1175: return;
1176: if (lower((char) key) == lower(e.getKeyChar())) {
1177: MenuSelectionManager manager = e
1178: .getMenuSelectionManager();
1179: doClick(manager);
1180: e.consume();
1181: }
1182: }
1183:
1184: public void menuKeyPressed(MenuKeyEvent e) {
1185: if (DEBUG) {
1186: System.out
1187: .println("in EclipseMenuItemUI.menuKeyPressed for "
1188: + menuItem.getText());
1189: }
1190: }
1191:
1192: public void menuKeyReleased(MenuKeyEvent e) {
1193: }
1194:
1195: private char lower(char keyChar) {
1196: return Character.toLowerCase(keyChar);
1197: }
1198: }
1199:
1200: private class PropertyChangeHandler implements
1201: PropertyChangeListener {
1202: public void propertyChange(PropertyChangeEvent e) {
1203: String name = e.getPropertyName();
1204:
1205: if (name.equals("labelFor")
1206: || name.equals("displayedMnemonic")
1207: || name.equals("accelerator")) {
1208: updateAcceleratorBinding();
1209: } else if (name.equals("text") || "font".equals(name)
1210: || "foreground".equals(name)) {
1211: // remove the old html view client property if one
1212: // existed, and install a new one if the text installed
1213: // into the JLabel is html source.
1214: JMenuItem lbl = ((JMenuItem) e.getSource());
1215: String text = lbl.getText();
1216: BasicHTML.updateRenderer(lbl, text);
1217: }
1218: }
1219: }
1220:
1221: private static class ClickAction extends AbstractAction {
1222: public void actionPerformed(ActionEvent e) {
1223: JMenuItem mi = (JMenuItem) e.getSource();
1224: MenuSelectionManager.defaultManager().clearSelectedPath();
1225: mi.doClick();
1226: }
1227: }
1228:
1229: /**
1230: * Call this method when a menu item is to be activated.
1231: * This method handles some of the details of menu item activation
1232: * such as clearing the selected path and messaging the
1233: * JMenuItem's doClick() method.
1234: *
1235: * @param msm A MenuSelectionManager. The visual feedback and
1236: * internal bookkeeping tasks are delegated to
1237: * this MenuSelectionManager. If <code>null</code> is
1238: * passed as this argument, the
1239: * <code>MenuSelectionManager.defaultManager</code> is
1240: * used.
1241: * @see MenuSelectionManager
1242: * @see JMenuItem#doClick(int)
1243: * @since 1.4
1244: */
1245: protected void doClick(MenuSelectionManager msm) {
1246: // Auditory cue
1247: // if (!isInternalFrameSystemMenu()) {
1248: // ActionMap map = menuItem.getActionMap();
1249: // if (map != null) {
1250: // Action audioAction = map.get(getPropertyPrefix() +
1251: // ".commandSound");
1252: // if (audioAction != null) {
1253: // pass off firing the Action to a utility method
1254: // BasicLookAndFeel lf = (BasicLookAndFeel)
1255: // UIManager.getLookAndFeel();
1256: // lf.playSound(audioAction);
1257: // }
1258: // }
1259: // }
1260: // // Visual feedback
1261: if (msm == null) {
1262: msm = MenuSelectionManager.defaultManager();
1263: }
1264: msm.clearSelectedPath();
1265: menuItem.doClick(0);
1266: }
1267:
1268: public ThemePainter getPainter() {
1269: return _painter;
1270: }
1271:
1272: protected boolean isDownArrowVisible(Container c) {
1273: if (c instanceof TopLevelMenuContainer
1274: && ((TopLevelMenuContainer) c).isMenuBar()) {
1275: return false;
1276: } else if (c instanceof TopLevelMenuContainer
1277: && !((TopLevelMenuContainer) c).isMenuBar()) {
1278: return true;
1279: } else if (c instanceof JMenuBar) {
1280: return false;
1281: } else {
1282: return true;
1283: }
1284: }
1285: }
|