summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-02-28 22:30:20 +0000
committerRoman Kennke <roman@kennke.org>2006-02-28 22:30:20 +0000
commit5b638519a63211709f317f05ea95c751ed1f5216 (patch)
tree7eaebc2f4bbe3731a4134632dd7f7582f9eb09f1
parentdf2013da5a955206377c892bfcb12faf5bf8317c (diff)
downloadclasspath-5b638519a63211709f317f05ea95c751ed1f5216.tar.gz
2006-02-28 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicScrollBarUI.java (getPreferredSize): Fixed add a fixed space between the buttons instead of something related to min/max. (installComponents): Create and install buttons here. (installDefaults): Don't create buttons here. * javax/swing/plaf/metal/MetalScrollBarUI.java (getMinimumThumbSize): Return (0,0) when UI is not yet installed. (getPreferredSize): New method.
-rw-r--r--ChangeLog11
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java42
-rw-r--r--javax/swing/plaf/metal/MetalScrollBarUI.java59
3 files changed, 86 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index f78bdca3a..0d4578772 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-02-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (getPreferredSize): Fixed add a fixed space between the buttons
+ instead of something related to min/max.
+ (installComponents): Create and install buttons here.
+ (installDefaults): Don't create buttons here.
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (getMinimumThumbSize): Return (0,0) when UI is not yet installed.
+ (getPreferredSize): New method.
+
2006-02-28 David Gilbert <david.gilbert@object-refinery.com>
* examples/gnu/classpath/examples/swing/Demo.java
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index a2f5b82db..c8713c934 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -653,19 +653,17 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
{
- width += incrButton.getPreferredSize().getWidth();
- width += decrButton.getPreferredSize().getWidth();
-
- width += (scrollbar.getMaximum() - scrollbar.getMinimum());
- height = UIManager.getInt("ScrollBar.width");
+ width += incrButton.getPreferredSize().getWidth();
+ width += decrButton.getPreferredSize().getWidth();
+ width += 16;
+ height = UIManager.getInt("ScrollBar.width");
}
else
{
- height += incrButton.getPreferredSize().getHeight();
- height += decrButton.getPreferredSize().getHeight();
-
- height += (scrollbar.getMaximum() - scrollbar.getMinimum());
- width = UIManager.getInt("ScrollBar.width");
+ height += incrButton.getPreferredSize().getHeight();
+ height += decrButton.getPreferredSize().getHeight();
+ height += 16;
+ width = UIManager.getInt("ScrollBar.width");
}
Insets insets = scrollbar.getInsets();
@@ -721,18 +719,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void installComponents()
{
- if (incrButton != null)
- scrollbar.add(incrButton);
- if (decrButton != null)
- scrollbar.add(decrButton);
- }
-
- /**
- * This method installs the defaults for the scrollbar specified by the
- * Basic Look and Feel.
- */
- protected void installDefaults()
- {
int orientation = scrollbar.getOrientation();
switch (orientation)
{
@@ -746,6 +732,18 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
break;
}
+ if (incrButton != null)
+ scrollbar.add(incrButton);
+ if (decrButton != null)
+ scrollbar.add(decrButton);
+ }
+
+ /**
+ * This method installs the defaults for the scrollbar specified by the
+ * Basic Look and Feel.
+ */
+ protected void installDefaults()
+ {
LookAndFeel.installColors(scrollbar, "ScrollBar.background",
"ScrollBar.foreground");
LookAndFeel.installBorder(scrollbar, "ScrollBar.border");
diff --git a/javax/swing/plaf/metal/MetalScrollBarUI.java b/javax/swing/plaf/metal/MetalScrollBarUI.java
index 0ff501f89..155bb8146 100644
--- a/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -41,6 +41,7 @@ package javax.swing.plaf.metal;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -48,6 +49,7 @@ import java.beans.PropertyChangeListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
+import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
@@ -465,11 +467,60 @@ public class MetalScrollBarUI extends BasicScrollBarUI
*/
protected Dimension getMinimumThumbSize()
{
- if (isFreeStanding)
- return MIN_THUMB_SIZE_FREE_STANDING;
+ Dimension retVal;
+ if (scrollbar != null)
+ {
+ if (isFreeStanding)
+ retVal = MIN_THUMB_SIZE_FREE_STANDING;
+ else
+ retVal = MIN_THUMB_SIZE;
+ }
else
- return MIN_THUMB_SIZE;
+ retVal = new Dimension(0, 0);
+ return retVal;
}
-
+
+ /**
+ * Returns the <code>preferredSize</code> for the specified scroll bar.
+ * For a vertical scrollbar the height is the sum of the preferred heights
+ * of the buttons plus <code>30</code>. The width is fetched from the
+ * <code>UIManager</code> property <code>ScrollBar.width</code>.
+ *
+ * For horizontal scrollbars the width is the sum of the preferred widths
+ * of the buttons plus <code>30</code>. The height is fetched from the
+ * <code>UIManager</code> property <code>ScrollBar.height</code>.
+ *
+ * @param c the scrollbar for which to calculate the preferred size
+ *
+ * @return the <code>preferredSize</code> for the specified scroll bar
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ int height;
+ int width;
+ height = width = 0;
+
+ if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
+ {
+ width += incrButton.getPreferredSize().getWidth();
+ width += decrButton.getPreferredSize().getWidth();
+ width += 30;
+ height = UIManager.getInt("ScrollBar.width");
+ }
+ else
+ {
+ height += incrButton.getPreferredSize().getHeight();
+ height += decrButton.getPreferredSize().getHeight();
+ height += 30;
+ width = UIManager.getInt("ScrollBar.width");
+ }
+
+ Insets insets = scrollbar.getInsets();
+
+ height += insets.top + insets.bottom;
+ width += insets.left + insets.right;
+
+ return new Dimension(width, height);
+ }
}