diff options
author | Roman Kennke <roman@kennke.org> | 2005-04-20 05:47:57 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2005-04-20 05:47:57 +0000 |
commit | 9257bcc8fa8f754fc85697a034c5677e34070a0d (patch) | |
tree | eec6fd2c91ed099ee33fc17329a909a8d892724e /libjava | |
parent | 4d23e5b880bccc4f4c5759dc3c22351dc5e58060 (diff) | |
download | gcc-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')
-rw-r--r-- | libjava/ChangeLog | 96 | ||||
-rw-r--r-- | libjava/javax/swing/JToolBar.java | 10 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicButtonUI.java | 6 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java | 9 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java | 13 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicScrollBarUI.java | 52 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java | 7 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalBorders.java | 192 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalButtonUI.java | 4 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalInternalFrameUI.java | 23 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalLookAndFeel.java | 9 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalScrollBarUI.java | 19 | ||||
-rw-r--r-- | libjava/javax/swing/plaf/metal/MetalSliderUI.java | 23 | ||||
-rw-r--r-- | libjava/javax/swing/tree/DefaultTreeSelectionModel.java | 231 |
14 files changed, 551 insertions, 143 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f989f1f..3e92407 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,99 @@ +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. + 2005-04-20 Michael Koch <konqueror@gmx.de> * java/net/URLConnection.java diff --git a/libjava/javax/swing/JToolBar.java b/libjava/javax/swing/JToolBar.java index 55f4c15..2b994a5 100644 --- a/libjava/javax/swing/JToolBar.java +++ b/libjava/javax/swing/JToolBar.java @@ -50,6 +50,7 @@ import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleStateSet; +import javax.swing.JButton; import javax.swing.plaf.ToolBarUI; /** @@ -742,6 +743,15 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible { // XXX: Sun says disable button but test cases show otherwise. super.addImpl(component, constraints, index); + + // if we added a Swing Button then adjust this a little + if (component instanceof AbstractButton) + { + AbstractButton b = (AbstractButton) component; + b.setRolloverEnabled(rollover); + b.updateUI(); + } + } // addImpl() /** 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 & 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 & Feel. + * + * @return a border for Toolbar buttons in the Metal Look & 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; } } diff --git a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java index 4fe69f4..05b9741 100644 --- a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java @@ -67,52 +67,52 @@ public class DefaultTreeSelectionModel public static final String SELECTION_MODE_PROPERTY = "selectionMode"; /** - * changeSupport + * Our Swing property change support. */ protected SwingPropertyChangeSupport changeSupport; /** - * selection + * The current selection. */ protected TreePath[] selection; /** - * listenerList + * Our TreeSelectionListeners. */ protected EventListenerList listenerList; /** - * rowMapper + * The current RowMapper. */ protected transient RowMapper rowMapper; /** - * listSelectionModel + * The current listSelectionModel. */ protected DefaultListSelectionModel listSelectionModel; /** - * selectionMode + * The current selection mode. */ protected int selectionMode; /** - * leadPath + * The path that has been added last. */ protected TreePath leadPath; /** - * leadIndex + * The index of the last added path. */ protected int leadIndex; /** - * leadRow + * The row of the last added path according to the RowMapper. */ protected int leadRow; /** - * Constructor DefaultTreeSelectionModel + * Constructs a new DefaultTreeSelectionModel. */ public DefaultTreeSelectionModel() { @@ -120,9 +120,12 @@ public class DefaultTreeSelectionModel } /** - * clone - * @exception CloneNotSupportedException TODO - * @return Object + * Creates a clone of this DefaultTreeSelectionModel with the same + * selection. + * + * @exception CloneNotSupportedException should not be thrown here + * + * @return a clone of this DefaultTreeSelectionModel */ public Object clone() throws CloneNotSupportedException { @@ -130,8 +133,9 @@ public class DefaultTreeSelectionModel } /** - * toString - * @return String + * Returns a string that shows this object's properties. + * + * @return a string that shows this object's properties */ public String toString() { @@ -161,8 +165,12 @@ public class DefaultTreeSelectionModel } /** - * setRowMapper - * @param value0 TODO + * Sets the RowMapper that should be used to map between paths and their + * rows. + * + * @param rowMapper the RowMapper to set + * + * @see {@link RowMapper */ public void setRowMapper(RowMapper value0) { @@ -170,8 +178,12 @@ public class DefaultTreeSelectionModel } /** - * getRowMapper - * @return RowMapper + * Returns the RowMapper that is currently used to map between paths and + * their rows. + * + * @return the current RowMapper + * + * @see {@link RowMapper */ public RowMapper getRowMapper() { @@ -179,8 +191,16 @@ public class DefaultTreeSelectionModel } /** - * setSelectionMode - * @param value0 TODO + * Sets the current selection mode. Possible values are + * {@link #SINGLE_TREE_SELECTION}, {@link CONTIGUOUS_TREE_SELECTION} + * and {@link #DISCONTIGUOUS_TREE_SELECTION}. + * + * @param mode the selection mode to be set + * + * @see {@link #getSelectionMode} + * @see {@link #SINGLE_TREE_SELECTION} + * @see {@link #CONTIGUOUS_TREE_SELECTION} + * @see {@link #DISCONTIGUOUS_TREE_SELECTION} */ public void setSelectionMode(int value0) { @@ -188,8 +208,14 @@ public class DefaultTreeSelectionModel } /** - * getSelectionMode - * @return int + * Returns the current selection mode. + * + * @return the current selection mode + * + * @see {@link #setSelectionMode} + * @see {@link #SINGLE_TREE_SELECTION} + * @see {@link #CONTIGUOUS_TREE_SELECTION} + * @see {@link #DISCONTIGUOUS_TREE_SELECTION} */ public int getSelectionMode() { @@ -197,8 +223,12 @@ public class DefaultTreeSelectionModel } /** - * setSelectionPath - * @param value0 TODO + * Sets this path as the only selection. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param path the path to set as selection */ public void setSelectionPath(TreePath value0) { @@ -206,8 +236,13 @@ public class DefaultTreeSelectionModel } /** - * setSelectionPaths - * @param value0 TODO + * Sets the paths as selection. This method checks for duplicates and + * removes them. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param paths the paths to set as selection */ public void setSelectionPaths(TreePath[] value0) { @@ -215,8 +250,13 @@ public class DefaultTreeSelectionModel } /** - * addSelectionPath - * @param value0 TODO + * Adds a path to the list of selected paths. This method checks if the + * path is already selected and doesn't add the same path twice. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param path the path to add to the selection */ public void addSelectionPath(TreePath value0) { @@ -224,8 +264,13 @@ public class DefaultTreeSelectionModel } /** - * addSelectionPaths - * @param value0 TODO + * Adds the paths to the list of selected paths. This method checks if the + * paths are already selected and doesn't add the same path twice. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param paths the paths to add to the selection */ public void addSelectionPaths(TreePath[] value0) { @@ -233,8 +278,12 @@ public class DefaultTreeSelectionModel } /** - * removeSelectionPath - * @param value0 TODO + * Removes the path from the selection. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param path the path to remove */ public void removeSelectionPath(TreePath value0) { @@ -242,8 +291,12 @@ public class DefaultTreeSelectionModel } /** - * removeSelectionPaths - * @param value0 TODO + * Removes the paths from the selection. + * + * If this changes the selection the registered TreeSelectionListeners + * are notified. + * + * @param paths the path to remove */ public void removeSelectionPaths(TreePath[] value0) { @@ -251,8 +304,10 @@ public class DefaultTreeSelectionModel } /** - * getSelectionPath - * @return TreePath + * Returns the first path in the selection. This is especially useful + * when the selectionMode is {@link #SINGLE_TREE_SELECTION}. + * + * @return the first path in the selection */ public TreePath getSelectionPath() { @@ -260,8 +315,9 @@ public class DefaultTreeSelectionModel } /** - * getSelectionPaths - * @return TreePath[] + * Returns the complete selection. + * + * @return the complete selection */ public TreePath[] getSelectionPaths() { @@ -269,8 +325,9 @@ public class DefaultTreeSelectionModel } /** - * getSelectionCount - * @return int + * Returns the number of paths in the selection. + * + * @return the number of paths in the selection */ public int getSelectionCount() { @@ -278,9 +335,12 @@ public class DefaultTreeSelectionModel } /** - * isPathSelected - * @param value0 TODO - * @return boolean + * Checks if a given path is in the selection. + * + * @param path the path to check + * + * @return <code>true</code> if the path is in the selection, + * <code>false</code> otherwise */ public boolean isPathSelected(TreePath value0) { @@ -288,8 +348,10 @@ public class DefaultTreeSelectionModel } /** - * isSelectionEmpty - * @return boolean + * Checks if the selection is empty. + * + * @return <code>true</code> if the selection is empty, + * <code>false</code> otherwise */ public boolean isSelectionEmpty() { @@ -297,7 +359,7 @@ public class DefaultTreeSelectionModel } /** - * clearSelection + * Removes all paths from the selection. */ public void clearSelection() { @@ -364,8 +426,9 @@ public class DefaultTreeSelectionModel } /** - * getSelectionRows - * @return int[] + * Returns the currently selected rows. + * + * @return the currently selected rows */ public int[] getSelectionRows() { @@ -373,8 +436,9 @@ public class DefaultTreeSelectionModel } /** - * getMinSelectionRow - * @return int + * Returns the smallest row index from the selection. + * + * @return the smallest row index from the selection */ public int getMinSelectionRow() { @@ -382,8 +446,9 @@ public class DefaultTreeSelectionModel } /** - * getMaxSelectionRow - * @return int + * Returns the largest row index from the selection. + * + * @return the largest row index from the selection */ public int getMaxSelectionRow() { @@ -391,9 +456,12 @@ public class DefaultTreeSelectionModel } /** - * isRowSelected - * @param value0 TODO - * @return boolean + * Checks if a particular row is selected. + * + * @param row the index of the row to check + * + * @return <code>true</code> if the row is in this selection, + * <code>false</code> otherwise */ public boolean isRowSelected(int value0) { @@ -401,7 +469,7 @@ public class DefaultTreeSelectionModel } /** - * resetRowSelection + * Updates the mappings from TreePaths to row indices. */ public void resetRowSelection() { @@ -459,7 +527,16 @@ public class DefaultTreeSelectionModel } /** - * insureRowContinuity + * Makes sure the currently selected paths are valid according to the + * current selectionMode. + * + * If the selectionMode is set to {@link CONTIGUOUS_TREE_SELECTION} + * and the selection isn't contiguous then the selection is reset to + * the first set of contguous paths. + * + * If the selectionMode is set to {@link SINGLE_TREE_SELECTION} + * and the selection has more than one path, the selection is reset to + * the contain only the first path. */ protected void insureRowContinuity() { @@ -467,9 +544,12 @@ public class DefaultTreeSelectionModel } /** - * arePathsContiguous - * @param value0 TODO - * @return boolean + * Returns <code>true</code> if the paths are contiguous or we + * have no RowMapper assigned. + * + * @param paths the paths to check for continuity + * @return <code>true</code> if the paths are contiguous or we + * have no RowMapper assigned */ protected boolean arePathsContiguous(TreePath[] value0) { @@ -477,9 +557,19 @@ public class DefaultTreeSelectionModel } /** - * canPathsBeAdded - * @param value0 TODO - * @return boolean + * Checks if the paths can be added. This returns <code>true</code> if: + * <ul> + * <li><code>paths</code> is <code>null</code> or empty</li> + * <li>we have no RowMapper assigned</li> + * <li>nothing is currently selected</li> + * <li>selectionMode is {@link DISCONTIGUOUS_TREE_SELECTION</li> + * <li>adding the paths to the selection still results in a contiguous set + * of paths</li> + * + * @param paths the paths to check + * + * @return <code>true</code> if the paths can be added with respect to the + * selectionMode */ protected boolean canPathsBeAdded(TreePath[] value0) { @@ -487,9 +577,12 @@ public class DefaultTreeSelectionModel } /** - * canPathsBeRemoved - * @param value0 TODO - * @return boolean + * Checks if the paths can be removed without breaking the continuity of + * the selection according to selectionMode. + * + * @param paths the paths to check + * @return <code>true</code> if the paths can be removed with respect to the + * selectionMode */ protected boolean canPathsBeRemoved(TreePath[] value0) { @@ -507,7 +600,7 @@ public class DefaultTreeSelectionModel } /** - * updateLeadIndex + * Updates the lead index instance field. */ protected void updateLeadIndex() { @@ -515,7 +608,7 @@ public class DefaultTreeSelectionModel } /** - * insureUniqueness + * Deprecated and not used. */ protected void insureUniqueness() { |