summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java42
1 files changed, 14 insertions, 28 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
index 2a3556a5db9..c8754a3e049 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -475,7 +475,6 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
menuItem.setHorizontalAlignment(SwingConstants.LEADING);
- menuItem.setOpaque(true);
}
/**
@@ -553,11 +552,20 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
- Dimension size = getPreferredSize(menuItem);
- Color foreground = g.getColor();
- g.setColor(bgColor);
- g.drawRect(0, 0, size.width, size.height);
- g.setColor(foreground);
+ // Menu item is considered to be highlighted when it is selected.
+ // But we don't want to paint the background of JCheckBoxMenuItems
+ ButtonModel mod = menuItem.getModel();
+ if ((menuItem.isSelected() && checkIcon == null) || (mod != null &&
+ mod.isArmed())
+ && (menuItem.getParent() instanceof MenuElement))
+ {
+ if (menuItem.isContentAreaFilled())
+ {
+ g.setColor(selectionBackground);
+ g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
+ }
+ }
+
}
/**
@@ -612,28 +620,6 @@ public class BasicMenuItemUI extends MenuItemUI
br.width += insets.right + insets.left;
br.height += insets.top + insets.bottom;
- // Menu item is considered to be highlighted when it is selected.
- // But we don't want to paint the background of JCheckBoxMenuItems
- ButtonModel mod = m.getModel();
- if ((m.isSelected() && checkIcon == null) || (mod != null &&
- mod.isArmed())
- && (m.getParent() instanceof MenuElement))
- {
- if (m.isContentAreaFilled())
- {
- g.setColor(selectionBackground);
- g.fillRect(br.x, br.y, br.width, br.height);
- }
- }
- else
- {
- if (m.isContentAreaFilled())
- {
- g.setColor(m.getBackground());
- g.fillRect(br.x, br.y, br.width, br.height);
- }
- }
-
// If this menu item is a JCheckBoxMenuItem then paint check icon
if (checkIcon != null)
{
OpenPOWER on IntegriCloud