Ok, I've got to flush some older patches. These are a small bunch of
minor fixes for the Metal L&F.
2007-04-03 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalButtonUI.java
(paintButtonPressed): Fill the whole button not only visibleRect.
* javax/swing/plaf/metal/MetalLookAndFeel.java
(LAF_defaults): Removed.
(getDefaults): Always fetch super's defaults.
* javax/swing/plaf/metal/MetalMenuBarUI.java
(update): Don't leave 2 pixel gap.
/Roman
--
http://kennke.org/blog/
Index: javax/swing/plaf/metal/MetalButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalButtonUI.java,v
retrieving revision 1.20
diff -u -1 -5 -r1.20 MetalButtonUI.java
--- javax/swing/plaf/metal/MetalButtonUI.java 22 Aug 2006 11:23:58 -0000 1.20
+++ javax/swing/plaf/metal/MetalButtonUI.java 3 Apr 2007 20:26:19 -0000
@@ -162,33 +162,32 @@
// This is overridden to be public, for whatever reason.
super.uninstallDefaults(button);
}
/**
* Paints the background of the button to indicate that it is in the
* "pressed" state.
*
* @param g the graphics context.
* @param b the button.
*/
protected void paintButtonPressed(Graphics g, AbstractButton b)
{
if (b.isContentAreaFilled())
{
- Rectangle area = b.getVisibleRect();
g.setColor(getSelectColor());
- g.fillRect(area.x, area.y, area.width, area.height);
+ g.fillRect(0, 0, b.getWidth(), b.getHeight());
}
}
/**
* Paints the focus rectangle around the button text and/or icon.
*
* @param g the graphics context.
* @param b the button.
* @param viewRect the button bounds.
* @param textRect the text bounds.
* @param iconRect the icon bounds.
*/
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
Rectangle textRect, Rectangle iconRect)
{
Index: javax/swing/plaf/metal/MetalLookAndFeel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v
retrieving revision 1.88
diff -u -1 -5 -r1.88 MetalLookAndFeel.java
--- javax/swing/plaf/metal/MetalLookAndFeel.java 10 Dec 2006 20:25:48 -0000 1.88
+++ javax/swing/plaf/metal/MetalLookAndFeel.java 3 Apr 2007 20:26:19 -0000
@@ -63,33 +63,30 @@
* {
* UIManager.setLookAndFeel(new MetalLookAndFeel());
* }
* catch (UnsupportedLookAndFeelException e)
* {
* e.printStackTrace();
* }</pre>
*/
public class MetalLookAndFeel extends BasicLookAndFeel
{
private static final long serialVersionUID = 6680646159193457980L;
/** The current theme. */
private static MetalTheme theme;
- /** The look and feel defaults. */
- private UIDefaults LAF_defaults;
-
/**
* Creates a new instance of the Metal look and feel.
*/
public MetalLookAndFeel()
{
// Nothing to do here.
}
/**
* Sets the current theme to a new instance of [EMAIL PROTECTED] DefaultMetalTheme}.
*/
protected void createDefaultTheme()
{
getCurrentTheme();
}
@@ -139,41 +136,34 @@
}
/**
* Returns the look and feel name.
*
* @return "MetalLookAndFeel".
*/
public String getName()
{
return "Metal";
}
public UIDefaults getDefaults()
{
createDefaultTheme();
- if (LAF_defaults == null)
- {
- LAF_defaults = super.getDefaults();
+ UIDefaults def = super.getDefaults();
- // add custom theme entries to the table
- if (theme != null)
- theme.addCustomEntriesToTable(LAF_defaults);
- }
-
- // Returns the default values for this look and feel.
- return LAF_defaults;
+ theme.addCustomEntriesToTable(def);
+ return def;
}
/**
* Returns the accelerator foreground color from the installed theme.
*
* @return The accelerator foreground color.
*/
public static ColorUIResource getAcceleratorForeground()
{
if (theme != null)
return theme.getAcceleratorForeground();
return null;
}
/**
Index: javax/swing/plaf/metal/MetalMenuBarUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java,v
retrieving revision 1.3
diff -u -1 -5 -r1.3 MetalMenuBarUI.java
--- javax/swing/plaf/metal/MetalMenuBarUI.java 3 Aug 2006 22:29:09 -0000 1.3
+++ javax/swing/plaf/metal/MetalMenuBarUI.java 3 Apr 2007 20:26:19 -0000
@@ -70,25 +70,25 @@
/**
* If the property <code>MenuBar.gradient</code> is set, then a gradient
* is painted as background, otherwise the normal superclass behaviour is
* called.
*/
public void update(Graphics g, JComponent c)
{
int height = c.getHeight();
if (c.isOpaque()
&& UIManager.get("MenuBar.gradient") != null
&& c.getBackground() instanceof UIResource
&& height > 2)
{
- MetalUtils.paintGradient(g, 0, 0, c.getWidth(), height - 2,
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), height,
SwingConstants.VERTICAL, "MenuBar.gradient");
paint(g, c);
}
else
super.update(g, c);
}
}