Sorry,
I attached the wrong patch. Here is the correct one.

@Mark: This is a small fix which may enter 0.92.

cya
Robert

Robert Schuster wrote:
> Hi,
> this fumbles a bit with the way the gradient and the border is painted for 
> JMenu
> components.
> 
> Still need to find out how 'they' manage to join the painting of a JMenu with 
> a
> adjacent JToolBar ...
> 
> 2006-08-04  Robert Schuster  <[EMAIL PROTECTED]>
> 
>         * javax/swing/plaf/metal/MetalMenuBarUI.java:
>         (update): Check size and paint smaller gradient.
>         * javax/swing/plaf/metal/MetalBorders.java:
>         (MenuBarBorder): Removed borderColor field.
>         (MenuBarBorder.paintBorder): Added note, fetch color from UIManager or
>         MetalLookAndFeel.
> 
> 
> cya
> Robert
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.35
diff -u -r1.35 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java	18 May 2006 17:07:36 -0000	1.35
+++ javax/swing/plaf/metal/MetalBorders.java	3 Aug 2006 22:21:18 -0000
@@ -926,15 +926,11 @@
     /** The border insets. */
     protected static Insets borderInsets = new Insets(1, 0, 1, 0);
     
-    // TODO: find where this color really comes from
-    private static Color borderColor = new Color(153, 153, 153);
-    
     /**
      * Creates a new border instance.
      */
     public MenuBarBorder()
     {
-      // Nothing to do here.
     }
     
     /**
@@ -951,7 +947,17 @@
     public void paintBorder(Component c, Graphics g, int x, int y, int w,
         int h)
     {
-      g.setColor(borderColor);
+      // Although it is not correct to decide on the static property
+      // currentTheme which color to use the RI does it like that.
+      // The trouble is that by simply changing the current theme to
+      // e.g. DefaultMetalLookAndFeel this method will use another color
+      // although a change in painting behavior should be expected only
+      // after setting a new look and feel and updating all components.
+      if(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+        g.setColor(UIManager.getColor("MenuBar.borderColor"));
+      else
+        g.setColor(MetalLookAndFeel.getControlShadow());
+      
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
     }
     
Index: javax/swing/plaf/metal/MetalMenuBarUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java,v
retrieving revision 1.2
diff -u -r1.2 MetalMenuBarUI.java
--- javax/swing/plaf/metal/MetalMenuBarUI.java	16 Jun 2006 12:54:46 -0000	1.2
+++ javax/swing/plaf/metal/MetalMenuBarUI.java	3 Aug 2006 22:21:18 -0000
@@ -1,5 +1,5 @@
 /* MetalMenuBarUI.java -- MenuBar UI for the Metal L&F
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -76,12 +76,15 @@
    */
   public void update(Graphics g, JComponent c)
   {
+    int height = c.getHeight();
     if (c.isOpaque()
         && UIManager.get("MenuBar.gradient") != null
-        && c.getBackground() instanceof UIResource)
+        && c.getBackground() instanceof UIResource
+        && height > 2)
       {
-        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), height - 2,
                                  SwingConstants.VERTICAL, "MenuBar.gradient");
+        
         paint(g, c);
       }
     else

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to