Index: javax/swing/plaf/metal/MetalBorders.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v retrieving revision 1.2 diff -u -r1.2 MetalBorders.java --- javax/swing/plaf/metal/MetalBorders.java 18 Apr 2005 07:45:18 -0000 1.2 +++ javax/swing/plaf/metal/MetalBorders.java 18 Apr 2005 23:02:32 -0000 @@ -49,6 +49,7 @@ import javax.swing.border.AbstractBorder; import javax.swing.border.Border; import javax.swing.plaf.BorderUIResource; +import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicGraphicsUtils; import javax.swing.plaf.basic.BasicBorders; @@ -79,6 +80,7 @@ */ public static class MetalButtonBorder extends AbstractBorder + implements UIResource { /** The borders insets. */ protected static Insets borderInsets = new Insets(3, 3, 3, 3); @@ -234,6 +236,91 @@ } /** + * A border implementation for popup menus. + */ + public static class PopupMenuBorder + extends AbstractBorder + implements UIResource + { + + /** The border's insets. */ + protected static Insets borderInsets = new Insets(2, 2, 1, 1); + + /** + * Constructs a new PopupMenuBorder. + */ + public PopupMenuBorder() + { + } + + /** + * Returns the insets of the border, creating a new Insets instance + * with each call. + * + * @param c the component for which we return the border insets + * (not used here) + */ + public Insets getBorderInsets(Component c) + { + return getBorderInsets(c, null); + } + + /** + * Returns the insets of the border, using the supplied Insets instance. + * + * @param c the component for which we return the border insets + * (not used here) + * @param i the Insets instance to fill with the Insets values + */ + public Insets getBorderInsets(Component c, Insets i) + { + Insets insets; + if (i == null) + insets = new Insets(borderInsets.top, borderInsets.left, + borderInsets.bottom, borderInsets.right); + else + { + insets = i; + insets.top = borderInsets.top; + insets.left = borderInsets.left; + insets.bottom = borderInsets.bottom; + insets.right = borderInsets.right; + } + + return insets; + } + + /** + * Paints the border for component c using the + * Graphics context g with the dimension + * x, y, w, h. + * + * @param c the component for which we paint the border + * @param g the Graphics context to use + * @param x the X coordinate of the upper left corner of c + * @param y the Y coordinate of the upper left corner of c + * @param w the width of c + * @param h the height of c + */ + public void paintBorder(Component c, Graphics g, int x, int y, int w, + int h) + { + Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow(); + Color light = MetalLookAndFeel.getPrimaryControlHighlight(); + + // draw dark outer border + g.setColor(darkShadow); + g.drawRect(x, y, w - 1, h - 1); + + // draw highlighted inner border (only top and left) + g.setColor(light); + g.drawLine(x + 1, y + 1, x + 1, y + h - 2); + g.drawLine(x + 1, y + 1, x + w - 2, y + 1); + } + + } + + /** * Returns a border for Swing buttons in the Metal Look & Feel. * * @return a border for Swing buttons in the Metal Look & Feel Index: javax/swing/plaf/metal/MetalLookAndFeel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v retrieving revision 1.15 diff -u -r1.15 MetalLookAndFeel.java --- javax/swing/plaf/metal/MetalLookAndFeel.java 18 Apr 2005 09:54:54 -0000 1.15 +++ javax/swing/plaf/metal/MetalLookAndFeel.java 18 Apr 2005 23:02:32 -0000 @@ -449,6 +449,9 @@ * * ScrollBar.background0xcccccc * + * PopupMenu.border + * new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder() + * * * * @param defaults the UIDefaults instance to which the values are added @@ -477,7 +480,8 @@ "MenuBar.font", getControlTextFont(), "MenuItem.background", new ColorUIResource(getControl()), "MenuItem.font", getControlTextFont(), - "ScrollBar.background", new ColorUIResource(getControl()) + "ScrollBar.background", new ColorUIResource(getControl()), + "PopupMenu.border", new MetalBorders.PopupMenuBorder() }; defaults.putDefaults(myDefaults); }