aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/plaf
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-04-20 05:47:57 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2005-04-20 05:47:57 +0000
commit9257bcc8fa8f754fc85697a034c5677e34070a0d (patch)
treeeec6fd2c91ed099ee33fc17329a909a8d892724e /libjava/javax/swing/plaf
parent4d23e5b880bccc4f4c5759dc3c22351dc5e58060 (diff)
downloadgcc-9257bcc8fa8f754fc85697a034c5677e34070a0d.zip
gcc-9257bcc8fa8f754fc85697a034c5677e34070a0d.tar.gz
gcc-9257bcc8fa8f754fc85697a034c5677e34070a0d.tar.bz2
2005-04-20 Roman Kennke <roman@kennke.org>
* javax/swing/plaf/basic/BasicButtonUI.java (paint): This should not care about margin and insets at the same time, as insets already include the margin through the border. * javax/swing/plaf/basic/BasicGraphicsUtils.java (getPreferredButtonSize): Likewise. * javax/swing/plaf/metal/MetalBorders.java (getBorderInsets): Likewise. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/basic/BasicOptionPaneUI.java (createMessageArea): The JPanel that holds the message area doesn't need to override getPreferredSize. This prevents some message components from rendering nicely. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/MetalInternalFrameUI.java (createUI): Do not share instances between components. * javax/swing/plaf/metal/MetalSliderUI.java (createUI): Do not share instances between components. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/MetalBorders: (PopupMenuBorder): Added. * javax/swing/plaf/metal/MetalLookAndFeel (initComponentDefaults): Added PopupMenuBorder. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/tree/DefaultTreeSelectionModel.java: Added API documentation all over the class. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/basic/BasicScrollPaneUI.java (installDefaults): Link managed JScrollPane in instance field. (uninstallDefaults): Unlink managed JScrollPane in instance field. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/basic/BasicScrollBarUI.java (PropertyChangeHandler.propertyChange): Add default to switch statement to avoid errors with unusual values for orientation. (installComponents): Likewise. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/MetalScrollBarUI.java: (createUI): Instances cannot be shared among JScrollPanes. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/MetalLookAndFeel.java (initComponentDefaults): Added defaults for Menu, MenuBar MenuEntry fonts. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/plaf/basic/BasicScrollBarUI.java (installUI): Install listeners after everything all, otherwise we get strange NPEs in some situations, especially with custom L&Fs. (createIncreaseButton): Orientation is expected to be SwingConstants.NORTH, ..SOUTH, ..WEST or ..EAST and not HORIZONTAL or VERTICAL. (createDecreaseButton): Orientation is expected to be SwingConstants.NORTH, ..SOUTH, ..WEST or ..EAST and not HORIZONTAL or VERTICAL. (installComponents): Orientation for buttons is expected to be SwingConstants.NORTH, ..SOUTH, ..WEST or ..EAST and not HORIZONTAL or VERTICAL. 2005-04-20 Roman Kennke <roman@kennke.org> * javax/swing/JToolBar.java (addImpl): Adjust added AbstractButtons to look and feel like toolbar buttons. * javax/swing/plaf/metal/MetalBorders.java: Adjusted insets of ButtonBorder. (RolloverMarginBorder): Added class for toolbar buttons. (getButtonBorder): Adjusted factory method to return a shared instance of button border. (getToolbarButtonBorder): Added factory method to return a shared instance of toolbar button border. (getMarginBorder): Added factory method to return a shared instance of margin border. * javax/swing/plaf/metal/MetalButtonUI.java (installDefauls): If button is child of a JToolBar then set special border on this button. From-SVN: r98439
Diffstat (limited to 'libjava/javax/swing/plaf')
-rw-r--r--libjava/javax/swing/plaf/basic/BasicButtonUI.java6
-rw-r--r--libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java9
-rw-r--r--libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java13
-rw-r--r--libjava/javax/swing/plaf/basic/BasicScrollBarUI.java52
-rw-r--r--libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java7
-rw-r--r--libjava/javax/swing/plaf/metal/MetalBorders.java192
-rw-r--r--libjava/javax/swing/plaf/metal/MetalButtonUI.java4
-rw-r--r--libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java23
-rw-r--r--libjava/javax/swing/plaf/metal/MetalLookAndFeel.java9
-rw-r--r--libjava/javax/swing/plaf/metal/MetalScrollBarUI.java19
-rw-r--r--libjava/javax/swing/plaf/metal/MetalSliderUI.java23
11 files changed, 283 insertions, 74 deletions
diff --git a/libjava/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/javax/swing/plaf/basic/BasicButtonUI.java
index ed352e7..15b715b 100644
--- a/libjava/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicButtonUI.java
@@ -247,14 +247,12 @@ public class BasicButtonUI extends ButtonUI
Rectangle tr = new Rectangle();
Rectangle ir = new Rectangle();
Rectangle vr = new Rectangle();
- Rectangle br = new Rectangle();
Font f = c.getFont();
g.setFont(f);
- SwingUtilities.calculateInnerArea(b, br);
- SwingUtilities.calculateInsetArea(br, b.getMargin(), vr);
+ SwingUtilities.calculateInnerArea(b, vr);
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
b.getText(),
currentIcon(b),
@@ -270,7 +268,7 @@ public class BasicButtonUI extends ButtonUI
|| b.isSelected())
paintButtonPressed(g, b);
else
- paintButtonNormal(g, br, c);
+ paintButtonNormal(g, vr, c);
paintIcon(g, c, ir);
if (text != null)
diff --git a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
index b1064f4..07be39d 100644
--- a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -595,7 +595,6 @@ public class BasicGraphicsUtils
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Insets insets = b.getInsets();
- Insets margin = b.getMargin();
viewRect = new Rectangle();
@@ -628,11 +627,11 @@ public class BasicGraphicsUtils
contentRect = textRect.union(iconRect);
- return new Dimension(insets.left + margin.left
+ return new Dimension(insets.left
+ contentRect.width
- + insets.right + margin.right,
- insets.top + margin.top
+ + insets.right,
+ insets.top
+ contentRect.height
- + insets.bottom + margin.bottom);
+ + insets.bottom);
}
}
diff --git a/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
index 7d5e014..95d53b0 100644
--- a/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -846,18 +846,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
messageArea.setLayout(new BorderLayout());
addIcon(messageArea);
- JPanel rightSide = new JPanel()
- {
- public Dimension getPreferredSize()
- {
- int w = Math.max(optionPane.getSize().width, minimumWidth);
- Insets i = optionPane.getInsets();
- Dimension orig = super.getPreferredSize();
- Dimension value = new Dimension(w - i.left - i.right - iconSize,
- orig.height);
- return value;
- }
- };
+ JPanel rightSide = new JPanel();
rightSide.setLayout(new GridBagLayout());
GridBagConstraints con = createConstraints();
diff --git a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
index 36939b2..5dd54af 100644
--- a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -152,8 +152,18 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
incrButton.removeMouseListener(buttonListener);
decrButton.removeMouseListener(buttonListener);
- incrButton = createIncreaseButton(scrollbar.getOrientation());
- decrButton = createDecreaseButton(scrollbar.getOrientation());
+ int orientation = scrollbar.getOrientation();
+ switch (orientation)
+ {
+ case (JScrollBar.HORIZONTAL):
+ incrButton = createIncreaseButton(EAST);
+ decrButton = createDecreaseButton(WEST);
+ break;
+ default:
+ incrButton = createIncreaseButton(SOUTH);
+ decrButton = createDecreaseButton(NORTH);
+ break;
+ }
incrButton.addMouseListener(buttonListener);
decrButton.addMouseListener(buttonListener);
calculatePreferredSize();
@@ -513,16 +523,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JButton createIncreaseButton(int orientation)
{
if (incrButton == null)
- incrButton = new BasicArrowButton((orientation == SwingConstants.HORIZONTAL)
- ? SwingConstants.EAST
- : SwingConstants.SOUTH);
+ incrButton = new BasicArrowButton(orientation);
else
- {
- if (orientation == SwingConstants.HORIZONTAL)
- ((BasicArrowButton) incrButton).setDirection(SwingConstants.EAST);
- else
- ((BasicArrowButton) incrButton).setDirection(SwingConstants.SOUTH);
- }
+ ((BasicArrowButton) incrButton).setDirection(orientation);
return incrButton;
}
@@ -537,16 +540,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JButton createDecreaseButton(int orientation)
{
if (decrButton == null)
- decrButton = new BasicArrowButton((orientation == SwingConstants.HORIZONTAL)
- ? SwingConstants.WEST
- : SwingConstants.NORTH);
+ decrButton = new BasicArrowButton(orientation);
else
- {
- if (orientation == SwingConstants.HORIZONTAL)
- ((BasicArrowButton) decrButton).setDirection(SwingConstants.WEST);
- else
- ((BasicArrowButton) decrButton).setDirection(SwingConstants.NORTH);
- }
+ ((BasicArrowButton) decrButton).setDirection(orientation);
return decrButton;
}
@@ -793,9 +789,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void installComponents()
{
- incrButton = createIncreaseButton(scrollbar.getOrientation());
+ int orientation = scrollbar.getOrientation();
+ switch (orientation)
+ {
+ case (JScrollBar.HORIZONTAL):
+ incrButton = createIncreaseButton(EAST);
+ decrButton = createDecreaseButton(WEST);
+ break;
+ default:
+ incrButton = createIncreaseButton(SOUTH);
+ decrButton = createDecreaseButton(NORTH);
+ break;
+ }
scrollbar.add(incrButton);
- decrButton = createDecreaseButton(scrollbar.getOrientation());
scrollbar.add(decrButton);
}
@@ -869,9 +875,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollTimer.setRepeats(true);
installComponents();
- installListeners();
installDefaults();
configureScrollBarColors();
+ installListeners();
calculatePreferredSize();
layoutContainer(scrollbar);
diff --git a/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java b/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java
index b4618b2..da924bb 100644
--- a/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -53,7 +53,10 @@ import javax.swing.plaf.ScrollPaneUI;
public class BasicScrollPaneUI extends ScrollPaneUI
implements ScrollPaneConstants
{
-
+
+ /** The Scrollpane for which the UI is provided by this class. */
+ protected JScrollPane scrollpane;
+
public static ComponentUI createUI(final JComponent c)
{
return new BasicScrollPaneUI();
@@ -61,6 +64,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI
protected void installDefaults(JScrollPane p)
{
+ scrollpane = p;
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
p.setForeground(defaults.getColor("ScrollPane.foreground"));
p.setBackground(defaults.getColor("ScrollPane.background"));
@@ -75,6 +79,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI
p.setBackground(null);
p.setFont(null);
p.setBorder(null);
+ scrollpane = null;
}
public void installUI(final JComponent c)
diff --git a/libjava/javax/swing/plaf/metal/MetalBorders.java b/libjava/javax/swing/plaf/metal/MetalBorders.java
index edcb888..8b7ebec 100644
--- a/libjava/javax/swing/plaf/metal/MetalBorders.java
+++ b/libjava/javax/swing/plaf/metal/MetalBorders.java
@@ -49,6 +49,7 @@ import javax.swing.JButton;
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;
@@ -61,21 +62,28 @@ import javax.swing.plaf.basic.BasicBorders;
public class MetalBorders
{
+ /** The shared instance for getButtonBorder(). */
+ private static Border buttonBorder;
+
+ /** The shared instance for getRolloverButtonBorder(). */
+ private static Border toolbarButtonBorder;
+
/**
* A MarginBorder that gets shared by multiple components.
* Created on demand by the private helper function {@link
* #getMarginBorder()}.
*/
- private static BasicBorders.MarginBorder sharedMarginBorder;
+ private static BasicBorders.MarginBorder marginBorder;
/**
* The border that is drawn around Swing buttons.
*/
public static class MetalButtonBorder
extends AbstractBorder
+ implements UIResource
{
/** The borders insets. */
- protected static Insets borderInsets = new Insets(2, 2, 2, 2);
+ protected static Insets borderInsets = new Insets(3, 3, 3, 3);
/**
* Creates a new instance of ButtonBorder.
@@ -166,6 +174,7 @@ public class MetalBorders
if (newInsets == null)
newInsets = new Insets(0, 0, 0, 0);
+ AbstractButton b = (AbstractButton) c;
newInsets.bottom = borderInsets.bottom;
newInsets.left = borderInsets.left;
newInsets.right = borderInsets.right;
@@ -174,6 +183,141 @@ public class MetalBorders
}
}
+ /**
+ * This border is used in Toolbar buttons as inner border.
+ */
+ static class RolloverMarginBorder extends AbstractBorder
+ {
+ /** The borders insets. */
+ protected static Insets borderInsets = new Insets(3, 3, 3, 3);
+
+ /**
+ * Creates a new instance of RolloverBorder.
+ */
+ public RolloverMarginBorder()
+ {
+ }
+
+ /**
+ * Returns the insets of the RolloverBorder.
+ *
+ * @param c the component for which the border is used
+ *
+ * @return the insets of the RolloverBorder
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Returns the insets of the RolloverMarginBorder in the specified
+ * Insets object.
+ *
+ * @param c the component for which the border is used
+ * @param newInsets the insets object where to put the values
+ *
+ * @return the insets of the RolloverMarginBorder
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(0, 0, 0, 0);
+
+ AbstractButton b = (AbstractButton) c;
+ Insets margin = b.getMargin();
+ newInsets.bottom = borderInsets.bottom;
+ newInsets.left = borderInsets.left;
+ newInsets.right = borderInsets.right;
+ newInsets.top = borderInsets.top;
+ return newInsets;
+ }
+ }
+
+ /**
+ * 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 <code>c</code> using the
+ * Graphics context <code>g</code> with the dimension
+ * <code>x, y, w, h</code>.
+ *
+ * @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 &amp; Feel.
@@ -182,24 +326,42 @@ public class MetalBorders
*/
public static Border getButtonBorder()
{
- Border outer = new MetalButtonBorder();
- Border inner = getMarginBorder();
-
- return new BorderUIResource.CompoundBorderUIResource(outer, inner);
+ if (buttonBorder == null)
+ {
+ Border outer = new MetalButtonBorder();
+ Border inner = getMarginBorder();
+ buttonBorder = new BorderUIResource.CompoundBorderUIResource
+ (outer, inner);
+ }
+ return buttonBorder;
}
/**
- * Returns a shared MarginBorder.
+ * Returns a border for Toolbar buttons in the Metal Look &amp; Feel.
+ *
+ * @return a border for Toolbar buttons in the Metal Look &amp; Feel
*/
- static Border getMarginBorder() // intentionally not public
+ static Border getToolbarButtonBorder()
{
- /* Swing is not designed to be thread-safe, so there is no
- * need to synchronize the access to the global variable.
- */
- if (sharedMarginBorder == null)
- sharedMarginBorder = new BasicBorders.MarginBorder();
-
- return sharedMarginBorder;
+ if (toolbarButtonBorder == null)
+ {
+ Border outer = new MetalButtonBorder();
+ Border inner = new RolloverMarginBorder();
+ toolbarButtonBorder = new BorderUIResource.CompoundBorderUIResource
+ (outer, inner);
+ }
+ return toolbarButtonBorder;
}
+ /**
+ * Returns a shared instance of {@link BasicBorders.MarginBorder}.
+ *
+ * @return a shared instance of {@link BasicBorders.MarginBorder}
+ */
+ static Border getMarginBorder()
+ {
+ if (marginBorder == null)
+ marginBorder = new BasicBorders.MarginBorder();
+ return marginBorder;
+ }
}
diff --git a/libjava/javax/swing/plaf/metal/MetalButtonUI.java b/libjava/javax/swing/plaf/metal/MetalButtonUI.java
index bfb26aa..7b9130e 100644
--- a/libjava/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/libjava/javax/swing/plaf/metal/MetalButtonUI.java
@@ -40,6 +40,7 @@ package javax.swing.plaf.metal;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
+import javax.swing.JToolBar;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
@@ -92,6 +93,9 @@ public class MetalButtonUI
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
button.setFont(defaults.getFont("Button.font"));
+
+ if (button.getParent() instanceof JToolBar)
+ button.setBorder(MetalBorders.getToolbarButtonBorder());
}
}
diff --git a/libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java b/libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java
index 883ec7f..f2f8e36 100644
--- a/libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java
+++ b/libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.plaf.ComponentUI;
@@ -47,9 +49,8 @@ public class MetalInternalFrameUI
extends BasicInternalFrameUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for JInternalFrames */
- private static MetalInternalFrameUI instance = null;
+ /** The instances of MetalInternalFrameUI*/
+ private static HashMap instances;
/**
* Constructs a new instance of MetalInternalFrameUI.
@@ -68,8 +69,20 @@ public class MetalInternalFrameUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalInternalFrameUI((JInternalFrame) component);
+ if (instances == null)
+ instances = new HashMap();
+
+
+ Object o = instances.get(component);
+ MetalInternalFrameUI instance;
+ if (o == null)
+ {
+ instance = new MetalInternalFrameUI((JInternalFrame) component);
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalInternalFrameUI) o;
+
return instance;
}
}
diff --git a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
index 917f6b4..db48a74 100644
--- a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -449,6 +449,9 @@ public class MetalLookAndFeel extends BasicLookAndFeel
* </tr><tr>
* <td>ScrollBar.background</td><td>0xcccccc</td>
* </tr><tr>
+ * <td>PopupMenu.border</td>
+ * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
+ * </tr><tr>
* </table>
*
* @param defaults the UIDefaults instance to which the values are added
@@ -472,9 +475,13 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Label.background", new ColorUIResource(getControl()),
"Label.font", getControlTextFont(),
"Menu.background", new ColorUIResource(getControl()),
+ "Menu.font", getControlTextFont(),
"MenuBar.background", new ColorUIResource(getControl()),
+ "MenuBar.font", getControlTextFont(),
"MenuItem.background", new ColorUIResource(getControl()),
- "ScrollBar.background", new ColorUIResource(getControl())
+ "MenuItem.font", getControlTextFont(),
+ "ScrollBar.background", new ColorUIResource(getControl()),
+ "PopupMenu.border", new MetalBorders.PopupMenuBorder()
};
defaults.putDefaults(myDefaults);
}
diff --git a/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java b/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java
index 6baceb5..e89ccc6 100644
--- a/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
@@ -48,7 +50,7 @@ public class MetalScrollBarUI
// FIXME: maybe replace by a Map of instances when this becomes stateful
/** The shared UI instance for JScrollBars. */
- private static MetalScrollBarUI instance = null;
+ private static HashMap instances = null;
/**
* Constructs a new instance of MetalScrollBarUI.
@@ -67,8 +69,19 @@ public class MetalScrollBarUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalScrollBarUI();
+ if (instances == null)
+ instances = new HashMap();
+
+ Object o = instances.get(component);
+ MetalScrollBarUI instance;
+ if (o == null)
+ {
+ instance = new MetalScrollBarUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalScrollBarUI) o;
+
return instance;
}
}
diff --git a/libjava/javax/swing/plaf/metal/MetalSliderUI.java b/libjava/javax/swing/plaf/metal/MetalSliderUI.java
index f6ca41f..fafd21d3 100644
--- a/libjava/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/libjava/javax/swing/plaf/metal/MetalSliderUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSliderUI;
@@ -46,9 +48,8 @@ public class MetalSliderUI
extends BasicSliderUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalSliderUIs */
- private static MetalSliderUI instance = null;
+ /** The UI instances for MetalSliderUIs */
+ private static HashMap instances;
/**
* Constructs a new instance of MetalSliderUI.
@@ -67,8 +68,20 @@ public class MetalSliderUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalSliderUI();
+ if (instances == null)
+ instances = new HashMap();
+
+
+ Object o = instances.get(component);
+ MetalSliderUI instance;
+ if (o == null)
+ {
+ instance = new MetalSliderUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalSliderUI) o;
+
return instance;
}
}