summaryrefslogtreecommitdiffstats
path: root/libjava/javax/swing/plaf
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/plaf')
-rw-r--r--libjava/javax/swing/plaf/BorderUIResource.java20
-rw-r--r--libjava/javax/swing/plaf/ComponentUI.java6
-rw-r--r--libjava/javax/swing/plaf/FileChooserUI.java4
-rw-r--r--libjava/javax/swing/plaf/IconUIResource.java6
-rw-r--r--libjava/javax/swing/plaf/ListUI.java6
-rw-r--r--libjava/javax/swing/plaf/PopupMenuUI.java5
-rw-r--r--libjava/javax/swing/plaf/SplitPaneUI.java6
-rw-r--r--libjava/javax/swing/plaf/TabbedPaneUI.java6
-rw-r--r--libjava/javax/swing/plaf/TextUI.java6
-rw-r--r--libjava/javax/swing/plaf/TreeUI.java6
-rw-r--r--libjava/javax/swing/plaf/basic/BasicArrowButton.java351
-rw-r--r--libjava/javax/swing/plaf/basic/BasicBorders.java8
-rw-r--r--libjava/javax/swing/plaf/basic/BasicButtonUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicColorChooserUI.java10
-rw-r--r--libjava/javax/swing/plaf/basic/BasicComboBoxEditor.java3
-rw-r--r--libjava/javax/swing/plaf/basic/BasicComboBoxRenderer.java4
-rw-r--r--libjava/javax/swing/plaf/basic/BasicComboBoxUI.java31
-rw-r--r--libjava/javax/swing/plaf/basic/BasicComboPopup.java280
-rw-r--r--libjava/javax/swing/plaf/basic/BasicDesktopIconUI.java4
-rw-r--r--libjava/javax/swing/plaf/basic/BasicDesktopPaneUI.java27
-rw-r--r--libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java6
-rw-r--r--libjava/javax/swing/plaf/basic/BasicIconFactory.java10
-rw-r--r--libjava/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java33
-rw-r--r--libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java16
-rw-r--r--libjava/javax/swing/plaf/basic/BasicListUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicLookAndFeel.java13
-rw-r--r--libjava/javax/swing/plaf/basic/BasicMenuBarUI.java24
-rw-r--r--libjava/javax/swing/plaf/basic/BasicMenuItemUI.java31
-rw-r--r--libjava/javax/swing/plaf/basic/BasicMenuUI.java14
-rw-r--r--libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java19
-rw-r--r--libjava/javax/swing/plaf/basic/BasicPasswordFieldUI.java6
-rw-r--r--libjava/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java10
-rw-r--r--libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java35
-rw-r--r--libjava/javax/swing/plaf/basic/BasicProgressBarUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicRootPaneUI.java4
-rw-r--r--libjava/javax/swing/plaf/basic/BasicScrollBarUI.java416
-rw-r--r--libjava/javax/swing/plaf/basic/BasicSeparatorUI.java16
-rw-r--r--libjava/javax/swing/plaf/basic/BasicSliderUI.java11
-rw-r--r--libjava/javax/swing/plaf/basic/BasicSpinnerUI.java5
-rw-r--r--libjava/javax/swing/plaf/basic/BasicSplitPaneDivider.java121
-rw-r--r--libjava/javax/swing/plaf/basic/BasicSplitPaneUI.java75
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java144
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTableHeaderUI.java85
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTableUI.java14
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTextAreaUI.java1
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTextFieldUI.java2
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTextPaneUI.java69
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTextUI.java33
-rw-r--r--libjava/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java11
-rw-r--r--libjava/javax/swing/plaf/basic/BasicToolBarUI.java14
-rw-r--r--libjava/javax/swing/plaf/basic/BasicToolTipUI.java69
-rw-r--r--libjava/javax/swing/plaf/basic/BasicTreeUI.java171
-rw-r--r--libjava/javax/swing/plaf/basic/BasicViewportUI.java66
-rw-r--r--libjava/javax/swing/plaf/basic/ComboPopup.java6
-rw-r--r--libjava/javax/swing/plaf/metal/MetalLookAndFeel.java4
57 files changed, 1279 insertions, 1089 deletions
diff --git a/libjava/javax/swing/plaf/BorderUIResource.java b/libjava/javax/swing/plaf/BorderUIResource.java
index c9ed0111644..6b61f48a090 100644
--- a/libjava/javax/swing/plaf/BorderUIResource.java
+++ b/libjava/javax/swing/plaf/BorderUIResource.java
@@ -1,5 +1,5 @@
/* BorderUIResource.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,14 +38,22 @@ exception statement from your version. */
package javax.swing.plaf;
-import javax.swing.border.*;
-import javax.swing.Icon;
-import java.io.Serializable;
+import java.awt.Color;
import java.awt.Component;
+import java.awt.Font;
import java.awt.Graphics;
import java.awt.Insets;
-import java.awt.Font;
-import java.awt.Color;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.EtchedBorder;
+import javax.swing.border.LineBorder;
+import javax.swing.border.MatteBorder;
+import javax.swing.border.TitledBorder;
/**
* A wrapper for {@link javax.swing.border.Border} that also
diff --git a/libjava/javax/swing/plaf/ComponentUI.java b/libjava/javax/swing/plaf/ComponentUI.java
index a2ca1f00941..80e60c8f1a7 100644
--- a/libjava/javax/swing/plaf/ComponentUI.java
+++ b/libjava/javax/swing/plaf/ComponentUI.java
@@ -1,5 +1,5 @@
-/* ComponentUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* ComponentUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,10 +40,10 @@ package javax.swing.plaf;
import java.awt.Dimension;
import java.awt.Graphics;
+
import javax.accessibility.Accessible;
import javax.swing.JComponent;
-
/**
* The abstract base class for all delegates that provide the
* pluggable look and feel for Swing components. User applications
diff --git a/libjava/javax/swing/plaf/FileChooserUI.java b/libjava/javax/swing/plaf/FileChooserUI.java
index 6031c4216b8..90371815419 100644
--- a/libjava/javax/swing/plaf/FileChooserUI.java
+++ b/libjava/javax/swing/plaf/FileChooserUI.java
@@ -1,5 +1,5 @@
/* FileChooserUI.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,9 +35,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf;
import java.io.File;
+
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileView;
diff --git a/libjava/javax/swing/plaf/IconUIResource.java b/libjava/javax/swing/plaf/IconUIResource.java
index ca1ee7dee10..3af16b757fe 100644
--- a/libjava/javax/swing/plaf/IconUIResource.java
+++ b/libjava/javax/swing/plaf/IconUIResource.java
@@ -1,5 +1,5 @@
-/* IconUIResource.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* IconUIResource.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,8 +41,8 @@ package javax.swing.plaf;
import java.awt.Component;
import java.awt.Graphics;
import java.io.Serializable;
-import javax.swing.Icon;
+import javax.swing.Icon;
/**
* An icon that is marked as <code>UIResource</code>, which
diff --git a/libjava/javax/swing/plaf/ListUI.java b/libjava/javax/swing/plaf/ListUI.java
index 71ec7704cc7..1639c41d3a9 100644
--- a/libjava/javax/swing/plaf/ListUI.java
+++ b/libjava/javax/swing/plaf/ListUI.java
@@ -1,5 +1,5 @@
-/* ListUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* ListUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,8 +40,8 @@ package javax.swing.plaf;
import java.awt.Point;
import java.awt.Rectangle;
-import javax.swing.JList;
+import javax.swing.JList;
/**
* An abstract base class for delegates that implement the pluggable
diff --git a/libjava/javax/swing/plaf/PopupMenuUI.java b/libjava/javax/swing/plaf/PopupMenuUI.java
index 1871b9b7985..7e71a4b2ecb 100644
--- a/libjava/javax/swing/plaf/PopupMenuUI.java
+++ b/libjava/javax/swing/plaf/PopupMenuUI.java
@@ -1,5 +1,5 @@
/* PopupMenuUI.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,14 +35,15 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf;
import java.awt.event.MouseEvent;
+
import javax.swing.JPopupMenu;
import javax.swing.Popup;
import javax.swing.PopupFactory;
-
/**
* An abstract base class for delegates that implement the pluggable
* look and feel for a <code>JPopupMenu</code>.
diff --git a/libjava/javax/swing/plaf/SplitPaneUI.java b/libjava/javax/swing/plaf/SplitPaneUI.java
index 020a54a626f..146db76644d 100644
--- a/libjava/javax/swing/plaf/SplitPaneUI.java
+++ b/libjava/javax/swing/plaf/SplitPaneUI.java
@@ -1,5 +1,5 @@
/* SplitPaneUI.java --
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,12 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package javax.swing.plaf;
+package javax.swing.plaf;
import java.awt.Graphics;
-import javax.swing.JSplitPane;
+import javax.swing.JSplitPane;
/**
* An abstract base class for delegates that implement the pluggable
diff --git a/libjava/javax/swing/plaf/TabbedPaneUI.java b/libjava/javax/swing/plaf/TabbedPaneUI.java
index 20c36c30c21..f0cf69919f2 100644
--- a/libjava/javax/swing/plaf/TabbedPaneUI.java
+++ b/libjava/javax/swing/plaf/TabbedPaneUI.java
@@ -1,5 +1,5 @@
-/* TabbedPaneUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* TabbedPaneUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,8 +39,8 @@ exception statement from your version. */
package javax.swing.plaf;
import java.awt.Rectangle;
-import javax.swing.JTabbedPane;
+import javax.swing.JTabbedPane;
/**
* An abstract base class for delegates that implement the pluggable
diff --git a/libjava/javax/swing/plaf/TextUI.java b/libjava/javax/swing/plaf/TextUI.java
index 14f89d6006e..b28dd372eef 100644
--- a/libjava/javax/swing/plaf/TextUI.java
+++ b/libjava/javax/swing/plaf/TextUI.java
@@ -1,5 +1,5 @@
-/* TextUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* TextUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,13 +40,13 @@ package javax.swing.plaf;
import java.awt.Point;
import java.awt.Rectangle;
+
import javax.swing.text.BadLocationException;
import javax.swing.text.EditorKit;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
import javax.swing.text.View;
-
/**
* An abstract base class for delegates that provide the user
* interface for text editors.
diff --git a/libjava/javax/swing/plaf/TreeUI.java b/libjava/javax/swing/plaf/TreeUI.java
index 55327e2a014..d4bee57cfe4 100644
--- a/libjava/javax/swing/plaf/TreeUI.java
+++ b/libjava/javax/swing/plaf/TreeUI.java
@@ -1,5 +1,5 @@
-/* TreeUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* TreeUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,10 +39,10 @@ exception statement from your version. */
package javax.swing.plaf;
import java.awt.Rectangle;
+
import javax.swing.JTree;
import javax.swing.tree.TreePath;
-
/**
* An abstract base class for delegates that provide the user
* interface for <code>JTree</code>.
diff --git a/libjava/javax/swing/plaf/basic/BasicArrowButton.java b/libjava/javax/swing/plaf/basic/BasicArrowButton.java
index 8354d06a0ce..f876a783fe2 100644
--- a/libjava/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/libjava/javax/swing/plaf/basic/BasicArrowButton.java
@@ -1,4 +1,4 @@
-/* BasicArrowButton.java
+/* BasicArrowButton.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,183 +35,98 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
-import java.awt.Insets;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.Polygon;
import java.awt.Rectangle;
-import javax.swing.border.Border;
-import javax.swing.Icon;
+
import javax.swing.JButton;
import javax.swing.SwingConstants;
-
+import javax.swing.border.Border;
/**
* This class draws simple arrow buttons for the Basic Look and Feel.
*/
public class BasicArrowButton extends JButton implements SwingConstants
{
- /**
- * A private helper class that draws icons.
- */
- private class arrowIcon implements Icon
- {
- /** The polygon that describes the icon. */
- private Polygon arrow;
-
- /** The size of the icon. */
- private int size = 10;
-
- /**
- * Creates a new arrowIcon object using the given arrow polygon.
- *
- * @param arrow The polygon that describes the arrow.
- */
- public arrowIcon(Polygon arrow)
- {
- this.arrow = arrow;
- }
-
- /**
- * Returns the height of the icon.
- *
- * @return The height of the icon.
- */
- public int getIconHeight()
- {
- return size;
- }
-
- /**
- * Returns the width of the icon.
- *
- * @return The width of the icon.
- */
- public int getIconWidth()
- {
- return size;
- }
-
- /**
- * Sets the size of the icon.
- *
- * @param size The size of the icon.
- */
- public void setSize(int size)
- {
- this.size = size;
- }
-
- /**
- * Sets the arrow polygon.
- *
- * @param arrow The arrow polygon.
- */
- public void setArrow(Polygon arrow)
- {
- this.arrow = arrow;
- }
-
- /**
- * Paints the icon.
- *
- * @param c The Component to paint for.
- * @param g The Graphics object to draw with.
- * @param x The X coordinate to draw at.
- * @param y The Y coordinate to draw at.
- */
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- Color arrowColor;
- if (c.isEnabled())
- arrowColor = darkShadow;
- else
- arrowColor = shadow;
-
- paintIconImpl(g, x, y, arrowColor);
- }
-
- /**
- * This method does the actual painting work.
- *
- * @param g The Graphics object to paint with.
- * @param x The x coordinate to paint at.
- * @param y The y coordinate to paint at.
- * @param arrowColor The color to paint the arrow with.
- */
- public void paintIconImpl(Graphics g, int x, int y, Color arrowColor)
- {
- g.translate(x, y);
+ /** The default size of the Arrow buttons. */
+ private static int defaultSize = 10;
- Color saved = g.getColor();
+ /** The Polygon that points up. */
+ private static Polygon upIcon = new Polygon(new int[] { 0, 5, 9 },
+ new int[] { 7, 2, 7 }, 3);
- g.setColor(arrowColor);
+ /** The Polygon that points down. */
+ private static Polygon downIcon = new Polygon(new int[] { 1, 5, 9 },
+ new int[] { 3, 7, 3 }, 3);
- g.fillPolygon(arrow);
+ /** The Polygon that points left. */
+ private static Polygon leftIcon = new Polygon(new int[] { 7, 3, 7 },
+ new int[] { 1, 5, 9 }, 3);
- g.setColor(saved);
- g.translate(-x, -y);
- }
- }
+ /** The Polygon that points right. */
+ private static Polygon rightIcon = new Polygon(new int[] { 3, 7, 3 },
+ new int[] { 1, 5, 9 }, 3);
/** The direction to point in. */
protected int direction;
- /** The color the arrow is painted in if disabled and the bottom and
- * right edges of the button. */
- private transient Color shadow = Color.gray;
+ /**
+ * The color the arrow is painted in if disabled and the bottom and right
+ * edges of the button.
+ */
+ private transient Color shadow = Color.GRAY;
- /** The color the arrow is painted in if enabled and the bottom and
- * right edges of the button. */
- private transient Color darkShadow = Color.BLACK;
+ /**
+ * The color the arrow is painted in if enabled and the bottom and right
+ * edges of the button.
+ */
+ private transient Color darkShadow = Color.DARK_GRAY;
/** The top and left edges of the button. */
- private transient Color highlight = Color.BLACK;
+ private transient Color highlight = Color.WHITE;
/** The border around the ArrowButton. */
- private transient Border tmpBorder = new Border()
- {
- public Insets getBorderInsets(Component c)
- {
- return new Insets(0, 0, 0, 0);
- }
-
- public boolean isBorderOpaque()
+ private transient Border buttonBorder = new Border()
{
- return false;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
- {
- Rectangle bounds = getBounds();
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(2, 2, 2, 2);
+ }
- Color saved = g.getColor();
- g.setColor(highlight);
+ public boolean isBorderOpaque()
+ {
+ return true;
+ }
- g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height);
- g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ Color saved = g.getColor();
+ g.setColor(highlight);
+
+ g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
- g.setColor(shadow);
+ g.setColor(shadow);
- g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1,
- bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
- g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1,
- bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
+ g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
+ g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
- g.setColor(darkShadow);
+ g.setColor(darkShadow);
- g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width,
- bounds.y + bounds.height);
- g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width,
- bounds.y + bounds.height);
+ g.drawLine(x, y + h, x + w, y + h);
+ g.drawLine(x + w, y, x + w, y + h);
- g.setColor(saved);
- }
- };
+ g.setColor(saved);
+ }
+ };
/**
* Creates a new BasicArrowButton object.
@@ -221,12 +136,12 @@ public class BasicArrowButton extends JButton implements SwingConstants
public BasicArrowButton(int direction)
{
super();
+ setBorder(buttonBorder);
setDirection(direction);
- setBorder(tmpBorder);
}
/**
- * Creates a new BasicArrowButton object with the given colors and
+ * Creates a new BasicArrowButton object with the given colors and
* direction.
*
* @param direction The direction to point in.
@@ -246,6 +161,16 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
+ * This method returns whether the focus can traverse to this component.
+ *
+ * @return Whether the focus can traverse to this component.
+ */
+ public boolean isFocusTraversable()
+ {
+ return false;
+ }
+
+ /**
* This method returns the direction of the arrow.
*
* @return The direction of the arrow.
@@ -262,22 +187,25 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public void setDirection(int dir)
{
- Polygon arrow = getArrow(dir, 10);
- if (getIcon() == null)
- setIcon(new arrowIcon(arrow));
- else
- ((arrowIcon) getIcon()).setArrow(arrow);
this.direction = dir;
}
/**
- * This method paints the arrow button.
+ * This method paints the arrow button. The painting is delegated to the
+ * paintTriangle method.
*
* @param g The Graphics object to paint with.
*/
public void paint(Graphics g)
{
super.paint(g);
+ Insets insets = getInsets();
+ Rectangle bounds = getBounds();
+ int x = insets.left
+ + (bounds.width - insets.left - insets.right - defaultSize) / 2;
+ int y = insets.top
+ + (bounds.height - insets.left - insets.right - defaultSize) / 2;
+ paintTriangle(g, x, y, defaultSize, direction, isEnabled());
}
/**
@@ -287,7 +215,11 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public Dimension getPreferredSize()
{
- return new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight());
+ Insets insets = getInsets();
+ int w = defaultSize + insets.left + insets.right;
+ int h = defaultSize + insets.top + insets.bottom;
+
+ return new Dimension(w, h);
}
/**
@@ -311,8 +243,8 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * The method paints a triangle with the given size and direction at
- * the given x and y coordinates.
+ * The method paints a triangle with the given size and direction at the
+ * given x and y coordinates.
*
* @param g The Graphics object to paint with.
* @param x The x coordinate to paint at.
@@ -324,61 +256,90 @@ public class BasicArrowButton extends JButton implements SwingConstants
public void paintTriangle(Graphics g, int x, int y, int size, int direction,
boolean isEnabled)
{
- Polygon arrow = getArrow(direction, size);
- arrowIcon arrowI = new arrowIcon(arrow);
- arrowI.setSize(size);
-
- Color arrowColor;
- if (isEnabled())
- arrowColor = darkShadow;
- else
- arrowColor = shadow;
-
- arrowI.paintIconImpl(g, x, y, arrowColor);
- }
-
- /**
- * This is a private helper that creates polygons for a given size
- * and direction.
- *
- * @param direction The direction of the arrow.
- * @param size The size of the arrow.
- *
- * @return A new arrow polygon.
- */
- private Polygon getArrow(int direction, int size)
- {
- Polygon arrow;
- double dsize = (double) size;
-
- int one = (int) (dsize * 1 / 10);
- int two = (int) (dsize * 2 / 10);
- int five = (int) (dsize * 5 / 10);
- int eight = (int) (dsize * 8 / 10);
-
+ Polygon arrow = null;
switch (direction)
{
case NORTH:
- arrow = new Polygon(new int[] { eight, five, one },
- new int[] { eight, one, eight }, 3);
+ arrow = upIcon;
break;
case SOUTH:
- arrow = new Polygon(new int[] { eight, five, two },
- new int[] { two, eight, two }, 3);
+ arrow = downIcon;
break;
case EAST:
case RIGHT:
- arrow = new Polygon(new int[] { two, eight, two },
- new int[] { two, five, eight }, 3);
+ arrow = rightIcon;
break;
case WEST:
case LEFT:
- arrow = new Polygon(new int[] { eight, two, eight },
- new int[] { two, five, eight }, 3);
+ arrow = leftIcon;
break;
- default:
- throw new IllegalArgumentException("Invalid direction given.");
}
- return arrow;
+
+ int[] xPoints = arrow.xpoints;
+ int[] yPoints = arrow.ypoints;
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+ x1 = y1 = x2 = y2 = 0;
+
+ if (size != defaultSize)
+ {
+ float scale = size * 1f / defaultSize;
+ for (int i = 0; i < 3; i++)
+ {
+ xPoints[i] *= scale;
+ yPoints[i] *= scale;
+ }
+ }
+ g.translate(x, y);
+
+ switch (direction)
+ {
+ case NORTH:
+ x1 = xPoints[0] + 2;
+ y1 = yPoints[0];
+ y2 = y1;
+ x2 = xPoints[2] - 1;
+ break;
+ case SOUTH:
+ x1 = xPoints[1];
+ y1 = yPoints[1] + 1;
+ x2 = xPoints[2] - 1;
+ y2 = yPoints[2];
+ break;
+ case LEFT:
+ case WEST:
+ x1 = xPoints[0] + 1;
+ y1 = yPoints[0] + 1;
+ x2 = x1;
+ y2 = yPoints[2] + 1;
+ break;
+ case RIGHT:
+ case EAST:
+ x1 = xPoints[2];
+ y1 = yPoints[2] + 1;
+ x2 = xPoints[1] - 1;
+ y2 = yPoints[1] + 1;
+ break;
+ }
+ Color saved = g.getColor();
+
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+
+ if (arrow != null)
+ g.fillPolygon(xPoints, yPoints, 3);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(xPoints, yPoints, 3);
+ g.setColor(Color.WHITE);
+ g.drawLine(x1, y1, x2, y2);
+ }
+ g.setColor(saved);
+ g.translate(-x, -y);
}
}
diff --git a/libjava/javax/swing/plaf/basic/BasicBorders.java b/libjava/javax/swing/plaf/basic/BasicBorders.java
index 7002d14332c..dd668e35331 100644
--- a/libjava/javax/swing/plaf/basic/BasicBorders.java
+++ b/libjava/javax/swing/plaf/basic/BasicBorders.java
@@ -1,5 +1,5 @@
-/* BasicBorders.java
- Copyright (C) 2003 Free Software Foundation, Inc.
+/* BasicBorders.java --
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,6 +44,7 @@ import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.io.Serializable;
+
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JButton;
@@ -55,11 +56,10 @@ import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
-import javax.swing.plaf.UIResource;
import javax.swing.plaf.BorderUIResource;
+import javax.swing.plaf.UIResource;
import javax.swing.text.JTextComponent;
-
/**
* Provides various borders for the Basic look and feel.
*
diff --git a/libjava/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/javax/swing/plaf/basic/BasicButtonUI.java
index df7ac4269f0..ed04d281254 100644
--- a/libjava/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicButtonUI.java
@@ -37,15 +37,12 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Rectangle;
-import java.awt.Stroke;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
@@ -205,7 +202,7 @@ public class BasicButtonUI extends ButtonUI
return d;
}
- static private Icon currentIcon(AbstractButton b)
+ private static Icon currentIcon(AbstractButton b)
{
Icon i = b.getIcon();
ButtonModel model = b.getModel();
diff --git a/libjava/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java b/libjava/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
index c7d88d1a6ae..a0cf5a43fec 100644
--- a/libjava/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
@@ -1,4 +1,4 @@
-/* BasicCheckBoxMenuItemUI.java
+/* BasicCheckBoxMenuItemUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,9 +35,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.event.MouseEvent;
+
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
@@ -46,7 +48,6 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
-
/**
* DOCUMENT ME!
*/
diff --git a/libjava/javax/swing/plaf/basic/BasicColorChooserUI.java b/libjava/javax/swing/plaf/basic/BasicColorChooserUI.java
index 1c2dcd69545..61af43bbf70 100644
--- a/libjava/javax/swing/plaf/basic/BasicColorChooserUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicColorChooserUI.java
@@ -1,4 +1,4 @@
-/* BasicColorChooserUI.java
+/* BasicColorChooserUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,17 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.BorderLayout;
-import java.awt.Component;
import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JColorChooser;
import javax.swing.JComponent;
import javax.swing.JPanel;
@@ -59,7 +56,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.plaf.ColorChooserUI;
import javax.swing.plaf.ComponentUI;
-
/**
* This is the UI Class for the JColorChooser in the Basic Look and Feel.
*/
diff --git a/libjava/javax/swing/plaf/basic/BasicComboBoxEditor.java b/libjava/javax/swing/plaf/basic/BasicComboBoxEditor.java
index a465ff9492b..b306af71d1d 100644
--- a/libjava/javax/swing/plaf/basic/BasicComboBoxEditor.java
+++ b/libjava/javax/swing/plaf/basic/BasicComboBoxEditor.java
@@ -35,18 +35,19 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+
import javax.swing.ComboBoxEditor;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.UIResource;
-
/**
* This is a component that is responsible for displaying/editting selected
* item in comboBox. By default, the JTextField is returned as
diff --git a/libjava/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/libjava/javax/swing/plaf/basic/BasicComboBoxRenderer.java
index 6bf6a74d5c9..5dc0f489e20 100644
--- a/libjava/javax/swing/plaf/basic/BasicComboBoxRenderer.java
+++ b/libjava/javax/swing/plaf/basic/BasicComboBoxRenderer.java
@@ -35,12 +35,13 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
-import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.io.Serializable;
+
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
@@ -51,7 +52,6 @@ import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.UIResource;
-
/**
* This class is renderer for the combo box.
*
diff --git a/libjava/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/javax/swing/plaf/basic/BasicComboBoxUI.java
index 851392a0f9f..3ba13a2a1e1 100644
--- a/libjava/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -58,7 +59,7 @@ import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.EventListener;
+
import javax.accessibility.Accessible;
import javax.swing.CellRendererPane;
import javax.swing.ComboBoxEditor;
@@ -66,21 +67,14 @@ import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
-import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
-import javax.swing.SwingConstants;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComboBoxUI;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.BasicGraphicsUtils;
-
/**
* UI Delegate for JComboBox
@@ -796,7 +790,7 @@ public class BasicComboBoxUI extends ComboBoxUI
currentValue,
-1,
isPressed,
- isPressed);
+ hasFocus);
if (! comboBox.isEnabled())
comp.setEnabled(false);
@@ -1127,8 +1121,9 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public void intervalRemoved(ListDataEvent e)
{
- // must determine if the size of the combo box should change
- // FIXME: need to implement
+ // recalculate display size of the JComboBox.
+ largestItemSize = getLargestItemSize();
+ comboBox.repaint();
}
}
@@ -1142,11 +1137,13 @@ public class BasicComboBoxUI extends ComboBoxUI
{
}
+ /**
+ * This method is invoked whenever bound property of JComboBox changes.
+ */
public void propertyChange(PropertyChangeEvent e)
{
if (e.getPropertyName().equals(JComboBox.ENABLED_CHANGED_PROPERTY))
{
- // disable arrow button
arrowButton.setEnabled(comboBox.isEnabled());
if (comboBox.isEditable())
@@ -1169,6 +1166,16 @@ public class BasicComboBoxUI extends ComboBoxUI
comboBox.revalidate();
comboBox.repaint();
}
+ else if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY))
+ {
+ // remove ListDataListener from old model and add it to new model
+ ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue();
+ if (oldModel != null)
+ oldModel.removeListDataListener(listDataListener);
+
+ if ((ComboBoxModel) e.getNewValue() != null)
+ comboBox.getModel().addListDataListener(listDataListener);
+ }
// FIXME: Need to handle changes in other bound properties.
}
diff --git a/libjava/javax/swing/plaf/basic/BasicComboPopup.java b/libjava/javax/swing/plaf/basic/BasicComboPopup.java
index 61d2dfbcdad..bec7f058f9d 100644
--- a/libjava/javax/swing/plaf/basic/BasicComboPopup.java
+++ b/libjava/javax/swing/plaf/basic/BasicComboPopup.java
@@ -35,10 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -52,16 +54,18 @@ import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
-import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPopupMenu;
+import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
@@ -70,7 +74,6 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
-
/**
* UI Delegate for ComboPopup
*
@@ -78,37 +81,32 @@ import javax.swing.event.PopupMenuListener;
*/
public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
+ /* Timer for autoscrolling */
protected Timer autoscrollTimer;
- /**
- * ComboBox associated with this popup
- */
+ /** ComboBox associated with this popup */
protected JComboBox comboBox;
- /*
- * FIXME: Document fields below
- */
+ /** FIXME: Need to document */
protected boolean hasEntered;
- protected boolean isAutoScrolling;
/**
- * ItemListener listening to the selection changes in the combo box
+ * Indicates whether the scroll bar located in popup menu with comboBox's
+ * list of items is currently autoscrolling. This happens when mouse event
+ * originated in the combo box and is dragged outside of its bounds
*/
+ protected boolean isAutoScrolling;
+
+ /** ItemListener listening to the selection changes in the combo box */
protected ItemListener itemListener;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected KeyListener keyListener;
- /**
- * JList which is used to display item is the combo box
- */
+ /** JList which is used to display item is the combo box */
protected JList list;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected ListDataListener listDataListener;
/**
@@ -123,14 +121,10 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected MouseMotionListener listMouseMotionListener;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected ListSelectionListener listSelectionListener;
- /**
- * MouseListener listening to mouse events occuring in the combo box
- */
+ /** MouseListener listening to mouse events occuring in the combo box */
protected MouseListener mouseListener;
/**
@@ -145,21 +139,19 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected PropertyChangeListener propertyChangeListener;
- /*
- * FIXME: Document fields below
- */
- protected static int SCROLL_DOWN = 1;
- protected static int SCROLL_UP = 0;
+ /** direction for scrolling down list of combo box's items */
+ protected static final int SCROLL_DOWN = 1;
+
+ /** direction for scrolling up list of combo box's items */
+ protected static final int SCROLL_UP = 0;
+
+ /** Indicates auto scrolling direction */
protected int scrollDirection;
- /**
- * JScrollPane that contains list portion of the combo box
- */
+ /** JScrollPane that contains list portion of the combo box */
protected JScrollPane scroller;
- /**
- * This field is not used
- */
+ /** This field is not used */
protected boolean valueIsAdjusting;
/**
@@ -171,19 +163,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
this.comboBox = comboBox;
installComboBoxListeners();
-
- // initialize list that will be used to display elements of the combo box
- this.list = createList();
- ((JLabel) list.getCellRenderer()).setHorizontalAlignment(SwingConstants.LEFT);
- configureList();
-
- // initialize scroller. Add list to the scroller.
- scroller = createScroller();
- configureScroller();
-
- // add scroller with list inside of it to JPopupMenu
- super.add(scroller);
-
+ configurePopup();
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
}
@@ -196,11 +176,21 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
// popup should have same width as the comboBox and should be hight anough
// to display number of rows equal to 'maximumRowCount' property
- int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount())
- + 4;
+ int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
+ list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
super.setPopupSize(cbBounds.width, popupHeight);
+ // Highlight selected item in the combo box's drop down list
+ if (comboBox.getSelectedIndex() != -1)
+ list.setSelectedIndex(comboBox.getSelectedIndex());
+
+ //scroll scrollbar s.t. selected item is visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int selectedIndex = comboBox.getSelectedIndex();
+ if (selectedIndex > comboBox.getMaximumRowCount())
+ scrollbar.setValue(getPopupHeightForRowCount(selectedIndex));
+
// location specified is relative to comboBox
super.show(comboBox, 0, cbBounds.height);
}
@@ -293,7 +283,10 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected void firePopupMenuWillBecomeVisible()
{
- // FIXME: Need to implement
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox));
}
/**
@@ -302,7 +295,10 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected void firePopupMenuWillBecomeInvisible()
{
- // FIXME: Need to implement
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox));
}
/**
@@ -311,7 +307,10 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected void firePopupMenuCanceled()
{
- // FIXME: Need to implement
+ PopupMenuListener[] ll = comboBox.getPopupMenuListeners();
+
+ for (int i = 0; i < ll.length; i++)
+ ll[i].popupMenuCanceled(new PopupMenuEvent(comboBox));
}
/**
@@ -440,11 +439,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
protected void configureList()
{
list.setModel(comboBox.getModel());
-
- if (comboBox.getItemCount() < comboBox.getMaximumRowCount())
- list.setVisibleRowCount(comboBox.getItemCount());
- else
- list.setVisibleRowCount(comboBox.getMaximumRowCount());
+ list.setVisibleRowCount(comboBox.getMaximumRowCount());
installListListeners();
}
@@ -493,7 +488,17 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected void configurePopup()
{
- // FIXME: Need to implement
+ // initialize list that will be used to display combo box's items
+ this.list = createList();
+ ((JLabel) list.getCellRenderer()).setHorizontalAlignment(SwingConstants.LEFT);
+ configureList();
+
+ // initialize scroller. Add list to the scroller.
+ scroller = createScroller();
+ configureScroller();
+
+ // add scroller with list inside of it to JPopupMenu
+ super.add(scroller);
}
/*
@@ -552,37 +557,68 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
}
/**
- * DOCUMENT ME!
+ * This method start scrolling combo box's list of items either up or down
+ * depending on the specified 'direction'
*
- * @param direction DOCUMENT ME!
+ * @param direction of the scrolling.
*/
protected void startAutoScrolling(int direction)
{
- // FIXME: Need to implement
+ // FIXME: add timer
+ isAutoScrolling = true;
+
+ if (direction == SCROLL_UP)
+ autoScrollUp();
+ else
+ autoScrollDown();
}
/**
- * DOCUMENT ME!
+ * This method stops scrolling the combo box's list of items
*/
protected void stopAutoScrolling()
{
- // FIXME: Need to implement
+ // FIXME: add timer
+ isAutoScrolling = false;
}
/**
- * DOCUMENT ME!
+ * This method scrolls up list of combo box's items up and highlights that
+ * just became visible.
*/
protected void autoScrollUp()
{
- // FIXME: Need to implement
+ // scroll up the scroll bar to make the item above visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_UP);
+
+ scrollbar.setValue(scrollbar.getValue() - scrollToNext);
+
+ // If we haven't reached the begging of the combo box's list of items,
+ // then highlight next element above currently highlighted element
+ if (list.getSelectedIndex() != 0)
+ list.setSelectedIndex(list.getSelectedIndex() - 1);
}
/**
- * DOCUMENT ME!
+ * This method scrolls down list of combo box's and highlights item in the
+ * list that just became visible.
*/
protected void autoScrollDown()
{
- // FIXME: Need to implement
+ // scroll scrollbar down to make next item visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_DOWN);
+ scrollbar.setValue(scrollbar.getValue() + scrollToNext);
+
+ // If we haven't reached the end of the combo box's list of items
+ // then highlight next element below currently highlighted element
+ if (list.getSelectedIndex() + 1 != comboBox.getItemCount())
+ list.setSelectedIndex(list.getSelectedIndex() + 1);
}
/**
@@ -643,8 +679,8 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
for (int i = 0; i < maxRowCount; i++)
{
Component comp = rend.getListCellRendererComponent(list,
- list.getModel()
- .getElementAt(i),
+ comboBox.getModel()
+ .getElementAt(i),
-1, false, false);
Dimension dim = comp.getPreferredSize();
totalHeight += dim.height;
@@ -712,15 +748,36 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
}
/**
- * This method is invoked whenever mouse is released
+ * This method is invoked whenever mouse event was originated in the combo
+ * box and released either in the combBox list of items or in the combo
+ * box itself.
*
* @param e MouseEvent that should be handled
*/
public void mouseReleased(MouseEvent e)
{
- // FIXME: should handle dragging events here, if
- // mouse was dragged and released over the list of combobox's items,
- // then item over which it was released should be selected.
+ // Get component over which mouse was released
+ Component src = (Component) e.getSource();
+ int x = e.getX();
+ int y = e.getY();
+ Component releasedComponent = SwingUtilities.getDeepestComponentAt(src,
+ x, y);
+
+ // if mouse was released inside the bounds of combo box then do nothing,
+ // Otherwise if mouse was released inside the list of combo box items
+ // then change selection and close popup
+ if (! (releasedComponent instanceof JComboBox))
+ {
+ // List model contains the item over which mouse is released,
+ // since it is updated every time the mouse is moved over a different
+ // item in the list. Now that the mouse is released we need to
+ // update model of the combo box as well.
+ comboBox.setSelectedIndex(list.getSelectedIndex());
+
+ if (isAutoScrolling)
+ stopAutoScrolling();
+ hide();
+ }
}
}
@@ -737,13 +794,70 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
}
+ /**
+ * This method is responsible for highlighting item in the drop down list
+ * over which the mouse is currently being dragged.
+ */
public void mouseDragged(MouseEvent e)
{
+ // convert point of the drag event relative to combo box list component
+ // figure out over which list cell the mouse is currently being dragged
+ // and highlight the cell. The list model is changed but the change has
+ // no effect on combo box's data model. The list model is changed so
+ // that the appropriate item would be highlighted in the combo box's
+ // list.
+ if (BasicComboPopup.this.isVisible())
+ {
+ int cbHeight = (int) comboBox.getPreferredSize().getHeight();
+ int popupHeight = BasicComboPopup.this.getSize().height;
+
+ // if mouse is dragged inside the the combo box's items list.
+ if (e.getY() > cbHeight && ! (e.getY() - cbHeight >= popupHeight))
+ {
+ int index = list.locationToIndex(new Point(e.getX(),
+ (int) (e.getY()
+ - cbHeight)));
+
+ int firstVisibleIndex = list.getFirstVisibleIndex();
+
+ // list.locationToIndex returns item's index that would
+ // be located at the specified point if the first item that
+ // is visible is item 0. However in the JComboBox it is not
+ // necessarily the case since list is contained in the
+ // JScrollPane so we need to adjust the index returned.
+ if (firstVisibleIndex != 0)
+ // FIXME: adjusted index here is off by one. I am adding one
+ // here to compensate for that. This should be
+ // index += firstVisibleIndex. Remove +1 once the bug is fixed.
+ index += firstVisibleIndex + 1;
+
+ list.setSelectedIndex(index);
+ }
+ else
+ {
+ // if mouse is being dragged at the bottom of combo box's list
+ // of items or at the very top then scroll the list in the
+ // desired direction.
+ boolean movingUP = e.getY() < cbHeight;
+ boolean movingDown = e.getY() > cbHeight;
+
+ if (movingUP)
+ {
+ scrollDirection = SCROLL_UP;
+ startAutoScrolling(SCROLL_UP);
+ }
+ else if (movingDown)
+ {
+ scrollDirection = SCROLL_DOWN;
+ startAutoScrolling(SCROLL_DOWN);
+ }
+ }
+ }
}
}
/**
- * ItemHandler is an item listener that listens to selection event occuring
+ * ItemHandler is an item listener that listens to selection events occuring
* in the combo box. FIXME: should specify here what it does when item is
* selected or deselected in the combo box list.
*/
@@ -803,9 +917,11 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
public void mouseMoved(MouseEvent anEvent)
{
- // FIXME: Need to implement
- // NOTE: the change isn't reflected in data model of the combo box.
- // The items are only highlited, but not selected
+ // Highlight list cells over which the mouse is located.
+ // This changes list model, but has no effect on combo box's data model
+ int index = list.locationToIndex(anEvent.getPoint());
+ list.setSelectedIndex(index);
+ list.repaint();
}
}
@@ -828,6 +944,12 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
revalidate();
repaint();
}
+ if (e.getPropertyName().equals(JComboBox.MODEL_CHANGED_PROPERTY))
+ {
+ list.setModel((ComboBoxModel) e.getNewValue());
+ revalidate();
+ repaint();
+ }
}
}
diff --git a/libjava/javax/swing/plaf/basic/BasicDesktopIconUI.java b/libjava/javax/swing/plaf/basic/BasicDesktopIconUI.java
index b37c2f1e839..4867c27d8ca 100644
--- a/libjava/javax/swing/plaf/basic/BasicDesktopIconUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicDesktopIconUI.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.BorderLayout;
@@ -50,6 +51,7 @@ import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
+
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
@@ -62,8 +64,6 @@ import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.DesktopIconUI;
-import javax.swing.plaf.DesktopPaneUI;
-
/**
* This class acts as the UI delegate for JDesktopIcons for the Basic look and feel.
diff --git a/libjava/javax/swing/plaf/basic/BasicDesktopPaneUI.java b/libjava/javax/swing/plaf/basic/BasicDesktopPaneUI.java
index 3d43b362636..a9e7ffceb7b 100644
--- a/libjava/javax/swing/plaf/basic/BasicDesktopPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicDesktopPaneUI.java
@@ -35,31 +35,25 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Insets;
import java.awt.event.ActionEvent;
-import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
+
import javax.swing.AbstractAction;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
-import javax.swing.JInternalFrame.JDesktopIcon;
import javax.swing.KeyStroke;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
-import javax.swing.event.MouseInputAdapter;
-import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.DesktopIconUI;
import javax.swing.plaf.DesktopPaneUI;
-
/**
* This class is the UI delegate for JDesktopPane for the Basic look and feel.
*/
@@ -267,24 +261,35 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
}
}
- /** The KeyStroke associated with closing JInternalFrames. */
+ /**
+ * The KeyStroke associated with closing JInternalFrames.
+ * @deprecated
+ */
protected KeyStroke closeKey;
- /** The KeyStroke associated with maximizing JInternalFrames. */
+ /**
+ * The KeyStroke associated with maximizing JInternalFrames.
+ * @deprecated
+ */
protected KeyStroke maximizeKey;
- /** The KeyStroke associated with minimizing JInternalFrames. */
+ /**
+ * The KeyStroke associated with minimizing JInternalFrames.
+ * @deprecated
+ */
protected KeyStroke minimizeKey;
/**
* The KeyStroke associated with navigating (forward?) through
* JInternalFrames.
+ * @deprecated
*/
protected KeyStroke navigateKey;
/**
* The KeyStroke associated with navigating (backward?) through
* JInternalFrames.
+ * @deprecated
*/
protected KeyStroke navigateKey2;
diff --git a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
index 0645a373c2b..b1064f48eaa 100644
--- a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -1,5 +1,5 @@
/* BasicGraphicsUtils.java
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -455,7 +455,9 @@ public class BasicGraphicsUtils
drawUnderline = (underlinedIndex >= 0) && (underlinedIndex < textLength);
- if (!(g instanceof Graphics2D))
+ // FIXME: unfortunately pango and cairo can't agree on metrics
+ // so for the time being we continue to *not* use TextLayouts.
+ if (true || !(g instanceof Graphics2D))
{
/* Fall-back. This is likely to produce garbage for any text
* containing right-to-left (Hebrew or Arabic) characters, even
diff --git a/libjava/javax/swing/plaf/basic/BasicIconFactory.java b/libjava/javax/swing/plaf/basic/BasicIconFactory.java
index 9f3a5ac5e86..a2acc81167b 100644
--- a/libjava/javax/swing/plaf/basic/BasicIconFactory.java
+++ b/libjava/javax/swing/plaf/basic/BasicIconFactory.java
@@ -1,5 +1,5 @@
-/* BasicIconFactory.java
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* BasicIconFactory.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,15 +38,17 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.io.Serializable;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Polygon;
+import java.io.Serializable;
+
import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
+
/**
* STUBBED
*/
@@ -54,7 +56,7 @@ public class BasicIconFactory implements Serializable
{
static final long serialVersionUID = 5605588811185324383L;
- static private class DummyIcon
+ private static class DummyIcon
implements Icon
{
public int getIconHeight() { return 10; }
diff --git a/libjava/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/libjava/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 3b8a2a20ca2..36bb4ec2e93 100644
--- a/libjava/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/libjava/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -7,6 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -34,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -52,6 +54,7 @@ import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
@@ -64,10 +67,8 @@ import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.event.InternalFrameEvent;
-import javax.swing.UIManager;
import javax.swing.UIDefaults;
-
+import javax.swing.UIManager;
/**
* This class acts as a titlebar for JInternalFrames.
@@ -77,7 +78,7 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* The Action responsible for closing the JInternalFrame.
*/
- protected class CloseAction extends AbstractAction
+ public class CloseAction extends AbstractAction
{
/**
* This method is called when something closes the JInternalFrame.
@@ -102,7 +103,7 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for iconifying the JInternalFrame.
*/
- protected class IconifyAction extends AbstractAction
+ public class IconifyAction extends AbstractAction
{
/**
* This method is called when the user wants to iconify the
@@ -128,7 +129,7 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for maximizing the JInternalFrame.
*/
- protected class MaximizeAction extends AbstractAction
+ public class MaximizeAction extends AbstractAction
{
/**
* This method is called when the user wants to maximize the
@@ -154,7 +155,7 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for dragging the JInternalFrame.
*/
- protected class MoveAction extends AbstractAction
+ public class MoveAction extends AbstractAction
{
/**
* This method is called when the user wants to drag the JInternalFrame.
@@ -171,7 +172,7 @@ public class BasicInternalFrameTitlePane extends JComponent
* This Action is responsible for restoring the JInternalFrame. Restoring
* the JInternalFrame is the same as setting the maximum property to false.
*/
- protected class RestoreAction extends AbstractAction
+ public class RestoreAction extends AbstractAction
{
/**
* This method is called when the user wants to restore the
@@ -197,7 +198,7 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This action is responsible for sizing the JInternalFrame.
*/
- protected class SizeAction extends AbstractAction
+ public class SizeAction extends AbstractAction
{
/**
* This method is called when the user wants to resize the JInternalFrame.
@@ -236,7 +237,7 @@ public class BasicInternalFrameTitlePane extends JComponent
* This class acts as the MenuBar for the TitlePane. Clicking on the Frame
* Icon in the top left corner will activate it.
*/
- protected class SystemMenuBar extends JMenuBar
+ public class SystemMenuBar extends JMenuBar
{
/**
* This method returns true if it can receive focus.
@@ -439,22 +440,22 @@ public class BasicInternalFrameTitlePane extends JComponent
}
/** The action command for the Close action. */
- protected static String CLOSE_CMD = "Close";
+ protected static final String CLOSE_CMD = "Close";
/** The action command for the Minimize action. */
- protected static String ICONIFY_CMD = "Minimize";
+ protected static final String ICONIFY_CMD = "Minimize";
/** The action command for the Maximize action. */
- protected static String MAXIMIZE_CMD = "Maximize";
+ protected static final String MAXIMIZE_CMD = "Maximize";
/** The action command for the Move action. */
- protected static String MOVE_CMD = "Move";
+ protected static final String MOVE_CMD = "Move";
/** The action command for the Restore action. */
- protected static String RESTORE_CMD = "Restore";
+ protected static final String RESTORE_CMD = "Restore";
/** The action command for the Size action. */
- protected static String SIZE_CMD = "Size";
+ protected static final String SIZE_CMD = "Size";
/** The action associated with closing the JInternalFrame. */
protected Action closeAction;
diff --git a/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 7101d427dd3..990a3e3f9e0 100644
--- a/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.AWTEvent;
@@ -42,29 +43,22 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
-import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
-import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
+
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
-import javax.swing.Icon;
-import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
@@ -77,7 +71,6 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.UIResource;
-
/**
* This is the UI delegate for the Basic look and feel for JInternalFrames.
*/
@@ -1053,7 +1046,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
/** The JComponent placed at the west region of the JInternalFrame. */
protected JComponent westPane;
- /** The Keystroke bound to open the menu. */
+ /**
+ * The Keystroke bound to open the menu.
+ * @deprecated
+ */
protected KeyStroke openMenuKey;
/** The TitlePane displayed at the top of the JInternalFrame. */
diff --git a/libjava/javax/swing/plaf/basic/BasicListUI.java b/libjava/javax/swing/plaf/basic/BasicListUI.java
index bd5c53b04ff..50bbb819f62 100644
--- a/libjava/javax/swing/plaf/basic/BasicListUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicListUI.java
@@ -1,4 +1,4 @@
-/* BasicListUI.java
+/* BasicListUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -48,6 +49,7 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
@@ -63,7 +65,6 @@ import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ListUI;
-
/**
* The Basic Look and Feel UI delegate for the
* JList.
diff --git a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java
index 689cd8f57af..40bf972f25e 100644
--- a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -46,6 +46,7 @@ import java.awt.event.KeyEvent;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.ResourceBundle;
+
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
@@ -137,6 +138,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI",
"TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI",
"TableUI", "javax.swing.plaf.basic.BasicTableUI",
+ "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
"TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI",
"TextFieldUI", "javax.swing.plaf.basic.BasicTextFieldUI",
"TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
@@ -900,8 +902,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"Tree.background", new ColorUIResource(Color.white),
"Tree.changeSelectionWithFocus", Boolean.TRUE,
- // XXX Don't use gif
- "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.gif")),
+ "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
+ "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
"Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
"Tree.editorBorder", new BorderUIResource.LineBorderUIResource(Color.lightGray),
"Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
@@ -949,13 +951,12 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl PAGE_DOWN", "scrollDownChangeLead"
}),
"Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
"Tree.foreground", new ColorUIResource(Color.black),
"Tree.hash", new ColorUIResource(Color.gray),
- // XXX Don't use gif
- "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.gif")),
+ "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
"Tree.leftChildIndent", new Integer(7),
- // XXX Don't use gif
- "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.gif")),
+ "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
"Tree.rightChildIndent", new Integer(13),
"Tree.rowHeight", new Integer(16),
"Tree.scrollsOnExpand", Boolean.TRUE,
diff --git a/libjava/javax/swing/plaf/basic/BasicMenuBarUI.java b/libjava/javax/swing/plaf/basic/BasicMenuBarUI.java
index f0bd73fa0bf..a1920fb5e31 100644
--- a/libjava/javax/swing/plaf/basic/BasicMenuBarUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicMenuBarUI.java
@@ -35,44 +35,24 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.Insets;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.BoxLayout;
-import javax.swing.ButtonModel;
-import javax.swing.Icon;
-import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
-import javax.swing.JMenu;
import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.KeyStroke;
-import javax.swing.MenuElement;
-import javax.swing.MenuSelectionManager;
-import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import javax.swing.event.MenuDragMouseEvent;
-import javax.swing.event.MenuDragMouseListener;
-import javax.swing.event.MenuEvent;
-import javax.swing.event.MenuKeyEvent;
-import javax.swing.event.MenuKeyListener;
-import javax.swing.event.MenuListener;
-import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
-import javax.swing.plaf.MenuItemUI;
-
/**
* UI Delegate for JMenuBar.
diff --git a/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java
index e52d3f63e79..da3f5598d05 100644
--- a/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -45,26 +46,21 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
-import java.awt.Stroke;
-import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
-import java.util.Vector;
-import javax.swing.AbstractButton;
-import javax.swing.ButtonModel;
+
import javax.swing.Icon;
-import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -76,7 +72,6 @@ import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuItemUI;
-
/**
* UI Delegate for JMenuItem.
*/
@@ -398,6 +393,9 @@ public class BasicMenuItemUI extends MenuItemUI
selectionBackground = defaults.getColor("MenuItem.selectionBackground");
selectionForeground = defaults.getColor("MenuItem.selectionForeground");
acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
+
+ menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
+ menuItem.setHorizontalAlignment(SwingConstants.LEADING);
}
/**
@@ -557,23 +555,14 @@ public class BasicMenuItemUI extends MenuItemUI
}
}
- // paint icon
- // FIXME: should paint different icon at different button state's.
- // i.e disabled icon when button is disabled.. etc.
- Icon i = m.getIcon();
- if (i != null)
- {
- i.paintIcon(c, g, vr.x, vr.y);
-
- // Adjust view rectangle, s.t text would be drawn after menu item's icon.
- vr.x += i.getIconWidth() + defaultTextIconGap;
- }
-
// paint text and user menu icon if it exists
- SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
+ Icon i = m.getIcon();
+ SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i,
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, tr,
defaultTextIconGap);
+ if (i != null)
+ i.paintIcon(c, g, ir.x, ir.y);
paintText(g, m, tr, m.getText());
diff --git a/libjava/javax/swing/plaf/basic/BasicMenuUI.java b/libjava/javax/swing/plaf/basic/BasicMenuUI.java
index 01dca763dbd..98af9546a4b 100644
--- a/libjava/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicMenuUI.java
@@ -35,26 +35,18 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
-import java.awt.Component;
import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
-import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -68,8 +60,6 @@ import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.MenuItemUI;
-
/**
* UI Delegate for JMenu
diff --git a/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
index 8a696b8cbc1..609fd11ab8a 100644
--- a/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -1,4 +1,4 @@
-/* BasicOptionPaneUI.java
+/* BasicOptionPaneUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.BorderLayout;
@@ -42,21 +43,19 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Polygon;
-import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
+
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
@@ -75,10 +74,8 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.OptionPaneUI;
-
/**
* This class is the UI delegate for JOptionPane in the Basic Look and Feel.
*/
@@ -475,7 +472,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
* A helper class that implements Icon. This is used temporarily until
* ImageIcons are fixed.
*/
- private static class messageIcon implements Icon
+ private static class MessageIcon implements Icon
{
/**
* This method returns the width of the icon.
@@ -512,7 +509,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
}
/** The icon displayed for ERROR_MESSAGE. */
- private static messageIcon errorIcon = new messageIcon()
+ private static MessageIcon errorIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -534,7 +531,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
};
/** The icon displayed for INFORMATION_MESSAGE. */
- private static messageIcon infoIcon = new messageIcon()
+ private static MessageIcon infoIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -560,7 +557,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
};
/** The icon displayed for WARNING_MESSAGE. */
- private static messageIcon warningIcon = new messageIcon()
+ private static MessageIcon warningIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -585,7 +582,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
};
/** The icon displayed for MESSAGE_ICON. */
- private static messageIcon questionIcon = new messageIcon()
+ private static MessageIcon questionIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
diff --git a/libjava/javax/swing/plaf/basic/BasicPasswordFieldUI.java b/libjava/javax/swing/plaf/basic/BasicPasswordFieldUI.java
index fe1c4902ac6..0350f7437f7 100644
--- a/libjava/javax/swing/plaf/basic/BasicPasswordFieldUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicPasswordFieldUI.java
@@ -41,6 +41,7 @@ package javax.swing.plaf.basic;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.Element;
+import javax.swing.text.PasswordView;
import javax.swing.text.View;
public class BasicPasswordFieldUI extends BasicTextFieldUI
@@ -49,6 +50,11 @@ public class BasicPasswordFieldUI extends BasicTextFieldUI
{
}
+ public View create(Element elem)
+ {
+ return new PasswordView(elem);
+ }
+
public static ComponentUI createUI(JComponent c)
{
return new BasicPasswordFieldUI();
diff --git a/libjava/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java b/libjava/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
index caa5f8ddd34..d0df9d3477c 100644
--- a/libjava/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
@@ -1,4 +1,4 @@
-/* BasicPopupMenuSeparatorUI.java
+/* BasicPopupMenuSeparatorUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,22 +35,18 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.Insets;
import java.awt.Rectangle;
+
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
-import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.SeparatorUI;
-
/**
* The Basic Look and Feel UI delegate for JPopupMenu.Separator.
diff --git a/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java b/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java
index 35fb005b9b9..796af5643cc 100644
--- a/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -37,58 +37,25 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.AWTKeyStroke;
-import java.awt.BasicStroke;
-import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.Stroke;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.EventListener;
-import javax.swing.AbstractButton;
-import javax.swing.ButtonModel;
-import javax.swing.Icon;
-import javax.swing.JCheckBoxMenuItem;
+
import javax.swing.JComponent;
-import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.MenuDragMouseEvent;
-import javax.swing.event.MenuDragMouseListener;
-import javax.swing.event.MenuKeyEvent;
-import javax.swing.event.MenuKeyListener;
import javax.swing.event.MouseInputListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.MenuItemUI;
import javax.swing.plaf.PopupMenuUI;
diff --git a/libjava/javax/swing/plaf/basic/BasicProgressBarUI.java b/libjava/javax/swing/plaf/basic/BasicProgressBarUI.java
index fa84267efa2..9398ab86c1b 100644
--- a/libjava/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -1,4 +1,4 @@
-/* BasicProgressBarUI.java
+/* BasicProgressBarUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -49,6 +50,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JComponent;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
@@ -61,7 +63,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ProgressBarUI;
-
/**
* The Basic Look and Feel UI delegate for the
* JProgressBar.
diff --git a/libjava/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java b/libjava/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
index a63c95fbc55..3b17f3608d0 100644
--- a/libjava/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
@@ -1,4 +1,4 @@
-/* BasicRadioButtonMenuItemUI.java
+/* BasicRadioButtonMenuItemUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,9 +35,11 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.event.MouseEvent;
+
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
@@ -46,7 +48,6 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
-
/**
* UI Delegator for JRadioButtonMenuItem
*/
diff --git a/libjava/javax/swing/plaf/basic/BasicRootPaneUI.java b/libjava/javax/swing/plaf/basic/BasicRootPaneUI.java
index 7201549a209..110200e58ab 100644
--- a/libjava/javax/swing/plaf/basic/BasicRootPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicRootPaneUI.java
@@ -1,4 +1,4 @@
-/* BasicPanelUI.java
+/* BasicPanelUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,12 +40,12 @@ package javax.swing.plaf.basic;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.RootPaneUI;
-
public class BasicRootPaneUI extends RootPaneUI
implements PropertyChangeListener
{
diff --git a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
index 913b3260b91..446726e8bf8 100644
--- a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -1,4 +1,4 @@
-/* BasicScrollBarUI.java
+/* BasicScrollBarUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -56,7 +57,6 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BoundedRangeModel;
-import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
@@ -70,7 +70,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollBarUI;
-
/**
* The Basic Look and Feel UI delegate for JScrollBar.
*/
@@ -78,15 +77,14 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
SwingConstants
{
/**
- * A helper class that listens to the two JButtons on each end
- * of the JScrollBar.
+ * A helper class that listens to the two JButtons on each end of the
+ * JScrollBar.
*/
protected class ArrowButtonListener extends MouseAdapter
{
/**
- * Move the thumb in the direction specified by the
- * button's arrow. If this button is held down, then
- * it should keep moving the thumb.
+ * Move the thumb in the direction specified by the button's arrow. If
+ * this button is held down, then it should keep moving the thumb.
*
* @param e The MouseEvent fired by the JButton.
*/
@@ -113,8 +111,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * A helper class that listens to the ScrollBar's model
- * for ChangeEvents.
+ * A helper class that listens to the ScrollBar's model for ChangeEvents.
*/
protected class ModelListener implements ChangeListener
{
@@ -127,7 +124,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
// System.err.println(this + ".stateChanged()");
calculatePreferredSize();
- layoutContainer(scrollbar);
+ layoutContainer(scrollbar);
getThumbBounds();
scrollbar.repaint();
}
@@ -157,19 +154,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
decrButton.removeMouseListener(buttonListener);
incrButton = createIncreaseButton(scrollbar.getOrientation());
decrButton = createDecreaseButton(scrollbar.getOrientation());
- incrButton.addMouseListener(buttonListener);
- decrButton.addMouseListener(buttonListener);
- calculatePreferredSize();
- layoutContainer(scrollbar);
- }
+ incrButton.addMouseListener(buttonListener);
+ decrButton.addMouseListener(buttonListener);
+ calculatePreferredSize();
+ layoutContainer(scrollbar);
+ }
layoutContainer(scrollbar);
scrollbar.repaint();
}
}
/**
- * A helper class that listens for events from
- * the timer that is used to move the thumb.
+ * A helper class that listens for events from the timer that is used to
+ * move the thumb.
*/
protected class ScrollListener implements ActionListener
{
@@ -180,8 +177,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
private transient boolean block;
/**
- * Creates a new ScrollListener object.
- * The default is scrolling positively with block movement.
+ * Creates a new ScrollListener object. The default is scrolling
+ * positively with block movement.
*/
public ScrollListener()
{
@@ -190,8 +187,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * Creates a new ScrollListener object using
- * the given direction and block.
+ * Creates a new ScrollListener object using the given direction and
+ * block.
*
* @param dir The direction to move in.
* @param block Whether movement will be in blocks.
@@ -234,8 +231,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
// Only need to check it if it's block scrolling
// We only block scroll if the click occurs
// in the track.
-
- if (!trackListener.shouldScroll(direction))
+ if (! trackListener.shouldScroll(direction))
{
trackHighlight = NO_HIGHLIGHT;
scrollbar.repaint();
@@ -260,13 +256,14 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
/** The current Y coordinate of the mouse. */
protected int currentMouseY;
- /** The offset between the current mouse cursor and the
- current value of the scrollbar. */
+ /**
+ * The offset between the current mouse cursor and the current value of
+ * the scrollbar.
+ */
protected int offset;
/**
- * This method is called when the mouse is being
- * dragged.
+ * This method is called when the mouse is being dragged.
*
* @param e The MouseEvent given.
*/
@@ -275,15 +272,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
currentMouseX = e.getX();
currentMouseY = e.getY();
if (scrollbar.getValueIsAdjusting())
- {
- int value;
- if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
- value = valueForXPosition(currentMouseX) - offset;
- else
- value = valueForYPosition(currentMouseY) - offset;
-
- scrollbar.setValue(value);
- }
+ {
+ int value;
+ if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
+ value = valueForXPosition(currentMouseX) - offset;
+ else
+ value = valueForYPosition(currentMouseY) - offset;
+
+ scrollbar.setValue(value);
+ }
}
/**
@@ -298,9 +295,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method is called when the mouse is
- * pressed. When it is pressed, the thumb should
- * move in blocks towards the cursor.
+ * This method is called when the mouse is pressed. When it is pressed,
+ * the thumb should move in blocks towards the cursor.
*
* @param e The MouseEvent given.
*/
@@ -318,7 +314,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
if (value == scrollbar.getValue())
return;
- if (!thumbRect.contains(e.getPoint()))
+ if (! thumbRect.contains(e.getPoint()))
{
scrollTimer.stop();
scrollListener.setScrollByBlock(true);
@@ -344,13 +340,13 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
// to that value.
scrollbar.setValueIsAdjusting(true);
offset = value - scrollbar.getValue();
- }
- scrollbar.repaint();
+ }
+ scrollbar.repaint();
}
/**
- * This method is called when the mouse is released.
- * It should stop movement on the thumb
+ * This method is called when the mouse is released. It should stop
+ * movement on the thumb
*
* @param e The MouseEvent given.
*/
@@ -358,32 +354,32 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
trackHighlight = NO_HIGHLIGHT;
scrollTimer.stop();
-
+
if (scrollbar.getValueIsAdjusting())
- scrollbar.setValueIsAdjusting(false);
+ scrollbar.setValueIsAdjusting(false);
scrollbar.repaint();
}
-
+
/**
- * A helper method that decides whether we should
- * keep scrolling in the given direction.
+ * A helper method that decides whether we should keep scrolling in the
+ * given direction.
*
* @param direction The direction to check for.
*
* @return Whether the thumb should keep scrolling.
*/
- public boolean shouldScroll (int direction)
+ public boolean shouldScroll(int direction)
{
int value;
if (scrollbar.getOrientation() == HORIZONTAL)
- value = valueForXPosition(currentMouseX);
+ value = valueForXPosition(currentMouseX);
else
- value = valueForYPosition(currentMouseY);
+ value = valueForYPosition(currentMouseY);
if (direction == POSITIVE_SCROLL)
- return (value > scrollbar.getValue());
+ return (value > scrollbar.getValue());
else
- return (value < scrollbar.getValue());
+ return (value < scrollbar.getValue());
}
}
@@ -393,8 +389,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
/** The listener that listens to the model. */
protected ModelListener modelListener;
- /** The listener that listens to the scrollbar for property
- changes. */
+ /** The listener that listens to the scrollbar for property changes. */
protected PropertyChangeListener propertyChangeListener;
/** The listener that listens to the timer. */
@@ -410,10 +405,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JButton incrButton;
/** The dimensions of the maximum thumb size. */
- protected static Dimension maximumThumbSize;
+ protected Dimension maximumThumbSize;
/** The dimensions of the minimum thumb size. */
- protected static Dimension minimumThumbSize;
+ protected Dimension minimumThumbSize;
/** The color of the thumb. */
protected Color thumbColor;
@@ -427,8 +422,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
/** The outer light shadow for the thumb. */
protected Color thumbLightShadowColor;
- /** The color that is used when the mouse press
- occurs in the track. */
+ /** The color that is used when the mouse press occurs in the track. */
protected Color trackHighlightColor;
/** The color of the track. */
@@ -441,19 +435,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected Rectangle thumbRect;
/** Indicates that the decrease highlight should be painted. */
- protected static int DECREASE_HIGHLIGHT = 1;
+ protected static final int DECREASE_HIGHLIGHT = 1;
/** Indicates that the increase highlight should be painted. */
- protected static int INCREASE_HIGHLIGHT = 2;
+ protected static final int INCREASE_HIGHLIGHT = 2;
/** Indicates that no highlight should be painted. */
- protected static int NO_HIGHLIGHT = 0;
+ protected static final int NO_HIGHLIGHT = 0;
/** Indicates that the scrolling direction is positive. */
- private static int POSITIVE_SCROLL = 1;
+ private static final int POSITIVE_SCROLL = 1;
/** Indicates that the scrolling direction is negative. */
- private static int NEGATIVE_SCROLL = -1;
+ private static final int NEGATIVE_SCROLL = -1;
/** The cached preferred size for the scrollbar. */
private transient Dimension preferredSize;
@@ -471,88 +465,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JScrollBar scrollbar;
/**
- * A helper class that allows us to draw icons for
- * the JButton.
- */
- private static class arrowIcon implements Icon
- {
- /** The polygon that describes the icon. */
- private Polygon arrow;
-
- /**
- * Creates a new arrowIcon object.
- *
- * @param arrow The polygon that describes the arrow.
- */
- public arrowIcon(Polygon arrow)
- {
- this.arrow = arrow;
- }
-
- /**
- * Returns the height of the icon.
- *
- * @return The height of the icon.
- */
- public int getIconHeight()
- {
- return 10;
- }
-
- /**
- * Returns the width of the icon.
- *
- * @return The width of the icon.
- */
- public int getIconWidth()
- {
- return 10;
- }
-
- /**
- * Paints the icon.
- *
- * @param c The Component to paint for.
- * @param g The Graphics object to draw with.
- * @param x The X coordinate to draw at.
- * @param y The Y coordinate to draw at.
- */
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- g.translate(x, y);
-
- Color saved = g.getColor();
-
- g.setColor(Color.BLACK);
-
- g.fillPolygon(arrow);
-
- g.setColor(saved);
- g.translate(-x, -y);
- }
- }
-
- /** The Icon that points up. */
- private static Icon upIcon = new arrowIcon(new Polygon(new int[] { 2, 5, 8 },
- new int[] { 7, 3, 7 },
- 3));
-
- /** The Icon that points down. */
- private static Icon downIcon = new arrowIcon(new Polygon(new int[] { 2, 5, 8 },
- new int[] { 3, 7, 3 },
- 3));
-
- /** The Icon that points left. */
- private static Icon leftIcon = new arrowIcon(new Polygon(new int[] { 7, 3, 7 },
- new int[] { 2, 5, 8 },
- 3));
-
- /** The Icon that points right. */
- private static Icon rightIcon = new arrowIcon(new Polygon(new int[] { 3, 7, 3},
- new int[] { 2, 5, 8},
- 3));
-
- /**
* This method adds a component to the layout.
*
* @param name The name to associate with the component that is added.
@@ -565,19 +477,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method configures the scrollbar's colors. This can be
- * done by looking up the standard colors from the Look and Feel defaults.
+ * This method configures the scrollbar's colors. This can be done by
+ * looking up the standard colors from the Look and Feel defaults.
*/
protected void configureScrollBarColors()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
+
trackColor = defaults.getColor("ScrollBar.track");
trackHighlightColor = defaults.getColor("ScrollBar.trackHighlight");
thumbColor = defaults.getColor("ScrollBar.thumb");
thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
- thumbLightShadowColor = defaults.getColor("ScrollBar.thumbLightShadow");
+ thumbLightShadowColor = defaults.getColor("ScrollBar.thumbLightShadow");
}
/**
@@ -590,9 +502,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
return new ArrowButtonListener();
}
- /**
- * This method creates a new JButton with the appropriate
- * icon for the orientation.
+ /**
+ * This method creates a new JButton with the appropriate icon for the
+ * orientation.
*
* @param orientation The orientation this JButton uses.
*
@@ -601,26 +513,22 @@ 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);
+ else
{
- incrButton = new JButton();
- incrButton.setMargin(new Insets(0,0,0,0));
- incrButton.setHorizontalAlignment(SwingConstants.CENTER);
- incrButton.setHorizontalTextPosition(SwingConstants.CENTER);
- incrButton.setVerticalAlignment(SwingConstants.CENTER);
- incrButton.setVerticalTextPosition(SwingConstants.CENTER);
+ if (orientation == SwingConstants.HORIZONTAL)
+ ((BasicArrowButton) incrButton).setDirection(SwingConstants.EAST);
+ else
+ ((BasicArrowButton) incrButton).setDirection(SwingConstants.SOUTH);
}
-
- if (orientation == SwingConstants.HORIZONTAL)
- incrButton.setIcon(rightIcon);
- else
- incrButton.setIcon(downIcon);
-
return incrButton;
}
/**
- * This method creates a new JButton with the appropriate
- * icon for the orientation.
+ * This method creates a new JButton with the appropriate icon for the
+ * orientation.
*
* @param orientation The orientation this JButton uses.
*
@@ -629,20 +537,16 @@ 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);
+ else
{
- decrButton = new JButton();
- decrButton.setMargin(new Insets(0,0,0,0));
- decrButton.setHorizontalAlignment(SwingConstants.CENTER);
- decrButton.setHorizontalTextPosition(SwingConstants.CENTER);
- decrButton.setVerticalAlignment(SwingConstants.CENTER);
- decrButton.setVerticalTextPosition(SwingConstants.CENTER);
+ if (orientation == SwingConstants.HORIZONTAL)
+ ((BasicArrowButton) decrButton).setDirection(SwingConstants.WEST);
+ else
+ ((BasicArrowButton) decrButton).setDirection(SwingConstants.NORTH);
}
-
- if (orientation == SwingConstants.HORIZONTAL)
- decrButton.setIcon(leftIcon);
- else
- decrButton.setIcon(upIcon);
-
return decrButton;
}
@@ -743,13 +647,12 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method calculates the preferred size since
- * calling getPreferredSize() returns a cached value.
+ * This method calculates the preferred size since calling
+ * getPreferredSize() returns a cached value.
*/
private void calculatePreferredSize()
{
// System.err.println(this + ".calculatePreferredSize()");
-
int height;
int width;
height = width = 0;
@@ -790,11 +693,11 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method returns a cached value of the preferredSize.
- * The only restrictions are: If the scrollbar is horizontal, the
- * height should be the maximum of the height of the JButtons and
- * the minimum width of the thumb. For vertical scrollbars, the
- * calculation is similar (swap width for height and vice versa).
+ * This method returns a cached value of the preferredSize. The only
+ * restrictions are: If the scrollbar is horizontal, the height should be
+ * the maximum of the height of the JButtons and the minimum width of the
+ * thumb. For vertical scrollbars, the calculation is similar (swap width
+ * for height and vice versa).
*
* @param c The JComponent to measure.
*
@@ -807,9 +710,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method returns the thumb's bounds based on the
- * current value of the scrollbar. This method updates the
- * cached value and returns that.
+ * This method returns the thumb's bounds based on the current value of the
+ * scrollbar. This method updates the cached value and returns that.
*
* @return The thumb bounds.
*/
@@ -821,24 +723,22 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
int extent = scrollbar.getVisibleAmount();
// System.err.println(this + ".getThumbBounds()");
-
if (max == min)
- {
- thumbRect.x = trackRect.x;
- thumbRect.y = trackRect.y;
- if (scrollbar.getOrientation() == HORIZONTAL)
{
- thumbRect.width = getMinimumThumbSize().width;
- thumbRect.height = trackRect.height;
- }
- else
- {
- thumbRect.width = trackRect.width;
- thumbRect.height = getMinimumThumbSize().height;
+ thumbRect.x = trackRect.x;
+ thumbRect.y = trackRect.y;
+ if (scrollbar.getOrientation() == HORIZONTAL)
+ {
+ thumbRect.width = getMinimumThumbSize().width;
+ thumbRect.height = trackRect.height;
+ }
+ else
+ {
+ thumbRect.width = trackRect.width;
+ thumbRect.height = getMinimumThumbSize().height;
+ }
+ return thumbRect;
}
- return thumbRect;
- }
-
if (scrollbar.getOrientation() == HORIZONTAL)
{
@@ -852,8 +752,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
else
{
thumbRect.x = trackRect.x;
- thumbRect.y = trackRect.y
- + value * trackRect.height / (max - min);
+ thumbRect.y = trackRect.y + value * trackRect.height / (max - min);
thumbRect.width = trackRect.width;
thumbRect.height = extent * trackRect.height / (max - min);
@@ -862,8 +761,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method calculates the bounds of the track. This method
- * updates the cached value and returns it.
+ * This method calculates the bounds of the track. This method updates the
+ * cached value and returns it.
*
* @return The track's bounds.
*/
@@ -889,8 +788,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method installs any addition Components that
- * are a part of or related to this scrollbar.
+ * This method installs any addition Components that are a part of or
+ * related to this scrollbar.
*/
protected void installComponents()
{
@@ -901,8 +800,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method installs the defaults for the scrollbar specified
- * by the Basic Look and Feel.
+ * This method installs the defaults for the scrollbar specified by the
+ * Basic Look and Feel.
*/
protected void installDefaults()
{
@@ -926,9 +825,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method installs any listeners for the scrollbar.
- * This method also installs listeners for things such as
- * the JButtons and the timer.
+ * This method installs any listeners for the scrollbar. This method also
+ * installs listeners for things such as the JButtons and the timer.
*/
protected void installListeners()
{
@@ -951,10 +849,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method installs the UI for the component.
- * This can include setting up listeners, defaults,
- * and components. This also includes initializing any data
- * objects.
+ * This method installs the UI for the component. This can include setting
+ * up listeners, defaults, and components. This also includes initializing
+ * any data objects.
*
* @param c The JComponent to install.
*/
@@ -977,7 +874,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
configureScrollBarColors();
calculatePreferredSize();
- layoutContainer(scrollbar);
+ layoutContainer(scrollbar);
}
}
@@ -1073,9 +970,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method is called when repainting and the mouse is
- * pressed in the track. It paints the track below the thumb
- * with the trackHighlight color.
+ * This method is called when repainting and the mouse is pressed in the
+ * track. It paints the track below the thumb with the trackHighlight
+ * color.
*
* @param g The Graphics object to paint with.
*/
@@ -1088,15 +985,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
g.fillRect(trackRect.x, trackRect.y, thumbRect.x - trackRect.x,
trackRect.height);
else
- g.fillRect(trackRect.x, trackRect.y, trackRect.width,
+ g.fillRect(trackRect.x, trackRect.y, trackRect.width,
thumbRect.y - trackRect.y);
g.setColor(saved);
}
/**
- * This method is called when repainting and the mouse is
- * pressed in the track. It paints the track above the thumb
- * with the trackHighlight color.
+ * This method is called when repainting and the mouse is pressed in the
+ * track. It paints the track above the thumb with the trackHighlight
+ * color.
*
* @param g The Graphics objet to paint with.
*/
@@ -1109,11 +1006,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
g.fillRect(thumbRect.x + thumbRect.width, trackRect.y,
trackRect.x + trackRect.width - thumbRect.x - thumbRect.width,
trackRect.height);
- else
- g.fillRect(trackRect.x, thumbRect.y + thumbRect.height,
- trackRect.width,
- trackRect.y + trackRect.height - thumbRect.y -
- thumbRect.height);
+ else
+ g.fillRect(trackRect.x, thumbRect.y + thumbRect.height, trackRect.width,
+ trackRect.y + trackRect.height - thumbRect.y
+ - thumbRect.height);
g.setColor(saved);
}
@@ -1217,25 +1113,25 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * The method scrolls the thumb by a block in the
- * direction specified.
+ * The method scrolls the thumb by a block in the direction specified.
*
* @param direction The direction to scroll.
*/
protected void scrollByBlock(int direction)
{
- scrollbar.setValue(scrollbar.getValue() + scrollbar.getBlockIncrement(direction));
+ scrollbar.setValue(scrollbar.getValue()
+ + scrollbar.getBlockIncrement(direction));
}
/**
- * The method scrolls the thumb by a unit in the
- * direction specified.
+ * The method scrolls the thumb by a unit in the direction specified.
*
* @param direction The direction to scroll.
*/
protected void scrollByUnit(int direction)
{
- scrollbar.setValue(scrollbar.getValue() + scrollbar.getUnitIncrement(direction));
+ scrollbar.setValue(scrollbar.getValue()
+ + scrollbar.getUnitIncrement(direction));
}
/**
@@ -1255,8 +1151,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method uninstalls any components that
- * are a part of or related to this scrollbar.
+ * This method uninstalls any components that are a part of or related to
+ * this scrollbar.
*/
protected void uninstallComponents()
{
@@ -1267,8 +1163,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method uninstalls any defaults that this
- * scrollbar acquired from the Basic Look and Feel defaults.
+ * This method uninstalls any defaults that this scrollbar acquired from the
+ * Basic Look and Feel defaults.
*/
protected void uninstallDefaults()
{
@@ -1278,8 +1174,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method uninstalls any keyboard
- * actions this scrollbar acquired during install.
+ * This method uninstalls any keyboard actions this scrollbar acquired
+ * during install.
*/
protected void uninstallKeyboardActions()
{
@@ -1287,22 +1183,21 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method uninstalls any listeners that
- * were registered during install.
+ * This method uninstalls any listeners that were registered during install.
*/
protected void uninstallListeners()
{
scrollTimer.removeActionListener(scrollListener);
-
+
scrollbar.getModel().removeChangeListener(modelListener);
scrollbar.removePropertyChangeListener(propertyChangeListener);
-
+
decrButton.removeMouseListener(buttonListener);
incrButton.removeMouseListener(buttonListener);
-
+
scrollbar.removeMouseListener(trackListener);
scrollbar.removeMouseMotionListener(trackListener);
-
+
propertyChangeListener = null;
modelListener = null;
buttonListener = null;
@@ -1311,10 +1206,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
- * This method uninstalls the UI. This includes
- * removing any defaults, listeners, and components
- * that this UI may have initialized. It also nulls
- * any instance data.
+ * This method uninstalls the UI. This includes removing any defaults,
+ * listeners, and components that this UI may have initialized. It also
+ * nulls any instance data.
*
* @param c The Component to uninstall for.
*/
@@ -1323,19 +1217,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
uninstallDefaults();
uninstallListeners();
uninstallComponents();
-
+
scrollTimer = null;
-
+
thumbRect = null;
trackRect = null;
-
+
trackColor = null;
trackHighlightColor = null;
thumbColor = null;
thumbHighlightColor = null;
thumbDarkShadowColor = null;
thumbLightShadowColor = null;
-
+
scrollbar = null;
}
diff --git a/libjava/javax/swing/plaf/basic/BasicSeparatorUI.java b/libjava/javax/swing/plaf/basic/BasicSeparatorUI.java
index 9149cb85d80..db2d164580f 100644
--- a/libjava/javax/swing/plaf/basic/BasicSeparatorUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicSeparatorUI.java
@@ -1,4 +1,4 @@
-/* BasicSeparatorUI.java
+/* BasicSeparatorUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,20 +35,22 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
-import java.awt.Dimension;
import java.awt.Color;
-import java.awt.Rectangle;
+import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
-import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.SeparatorUI;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
+import java.awt.Rectangle;
+
import javax.swing.JComponent;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SeparatorUI;
/**
* The Basic Look and Feel UI delegate for JSeparator.
diff --git a/libjava/javax/swing/plaf/basic/BasicSliderUI.java b/libjava/javax/swing/plaf/basic/BasicSliderUI.java
index b5c95cb68c3..648e332639b 100644
--- a/libjava/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicSliderUI.java
@@ -1,4 +1,4 @@
-/* BasicSliderUI.java
+/* BasicSliderUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -58,6 +59,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Dictionary;
import java.util.Enumeration;
+
import javax.swing.BoundedRangeModel;
import javax.swing.JComponent;
import javax.swing.JLabel;
@@ -72,7 +74,6 @@ import javax.swing.event.MouseInputAdapter;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SliderUI;
-
/**
* <p>
* BasicSliderUI.java This is the UI delegate in the Basic look and feel that
@@ -320,7 +321,7 @@ public class BasicSliderUI extends SliderUI
/**
* Helper class that listens for mouse events.
*/
- protected class TrackListener extends MouseInputAdapter
+ public class TrackListener extends MouseInputAdapter
{
/** The current X position of the mouse. */
protected int currentMouseX;
@@ -1955,10 +1956,10 @@ public class BasicSliderUI extends SliderUI
}
g.setColor(Color.WHITE);
- g.drawPolygon(bright);
+ g.drawPolyline(bright.xpoints, bright.ypoints, bright.npoints);
g.setColor(Color.BLACK);
- g.drawPolygon(dark);
+ g.drawPolyline(dark.xpoints, dark.ypoints, dark.npoints);
g.setColor(Color.GRAY);
g.fillPolygon(all);
diff --git a/libjava/javax/swing/plaf/basic/BasicSpinnerUI.java b/libjava/javax/swing/plaf/basic/BasicSpinnerUI.java
index 0f5e761d3d7..919cde78670 100644
--- a/libjava/javax/swing/plaf/basic/BasicSpinnerUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicSpinnerUI.java
@@ -1,5 +1,5 @@
/* SpinnerUI.java --
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Component;
@@ -48,6 +49,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JSpinner;
@@ -57,7 +59,6 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SpinnerUI;
-
/**
* DOCUMENT ME!
*
diff --git a/libjava/javax/swing/plaf/basic/BasicSplitPaneDivider.java b/libjava/javax/swing/plaf/basic/BasicSplitPaneDivider.java
index e06eb05f580..1ee1bb6d993 100644
--- a/libjava/javax/swing/plaf/basic/BasicSplitPaneDivider.java
+++ b/libjava/javax/swing/plaf/basic/BasicSplitPaneDivider.java
@@ -1,4 +1,4 @@
-/* BasicSplitPaneDivider.java
+/* BasicSplitPaneDivider.java --
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -49,12 +50,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.swing.JButton;
import javax.swing.JSplitPane;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
-
/**
* The divider that separates the two parts of a JSplitPane in the Basic look
* and feel.
@@ -153,32 +154,35 @@ public class BasicSplitPaneDivider extends Container
// left (top), middle, right(bottom)
// 0 1 2
- /** Keeps track of where the divider should be placed when using one touch expand
- * buttons. */
+ /**
+ * Keeps track of where the divider should be placed when using one touch
+ * expand buttons.
+ */
private transient int currentDividerLocation = 1;
private transient Border tmpBorder = new Border()
- {
- public Insets getBorderInsets(Component c)
{
- return new Insets(2, 2, 2, 2);
- }
-
- public boolean isBorderOpaque()
- {
- return false;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
- {
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
-
- g.drawRect(x + 2, y + 2, width - 4, height - 4);
-
- g.setColor(saved);
- }
- };
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(2, 2, 2, 2);
+ }
+
+ public boolean isBorderOpaque()
+ {
+ return false;
+ }
+
+ public void paintBorder(Component c, Graphics g, int x, int y,
+ int width, int height)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+
+ g.drawRect(x + 2, y + 2, width - 4, height - 4);
+
+ g.setColor(saved);
+ }
+ };
/**
* Constructs a new divider.
@@ -420,7 +424,7 @@ public class BasicSplitPaneDivider extends Container
if (orientation == JSplitPane.VERTICAL_SPLIT)
dir = SwingConstants.NORTH;
JButton button = new BasicArrowButton(dir);
- button.setBorderPainted(false);
+ button.setBorder(null);
return button;
}
@@ -437,7 +441,7 @@ public class BasicSplitPaneDivider extends Container
if (orientation == JSplitPane.VERTICAL_SPLIT)
dir = SwingConstants.SOUTH;
JButton button = new BasicArrowButton(dir);
- button.setBorderPainted(false);
+ button.setBorder(null);
return button;
}
@@ -484,11 +488,10 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This helper method moves the divider to one of the
- * three locations when using one touch expand buttons.
- * Location 0 is the left (or top) most location.
- * Location 1 is the middle.
- * Location 2 is the right (or bottom) most location.
+ * This helper method moves the divider to one of the three locations when
+ * using one touch expand buttons. Location 0 is the left (or top) most
+ * location. Location 1 is the middle. Location 2 is the right (or bottom)
+ * most location.
*
* @param locationIndex The location to move to.
*/
@@ -612,8 +615,10 @@ public class BasicSplitPaneDivider extends Container
*/
protected class DragController
{
- /** The difference between where the mouse is clicked and the
- * initial divider location. */
+ /**
+ * The difference between where the mouse is clicked and the initial
+ * divider location.
+ */
transient int offset;
/**
@@ -650,8 +655,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method returns one of the two paramters
- * for the orientation. In this case, it returns x.
+ * This method returns one of the two paramters for the orientation. In
+ * this case, it returns x.
*
* @param x The x coordinate.
* @param y The y coordinate.
@@ -664,8 +669,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method is called to pass on the drag information
- * to the UI through dragDividerTo.
+ * This method is called to pass on the drag information to the UI through
+ * dragDividerTo.
*
* @param newX The x coordinate of the MouseEvent.
* @param newY The y coordinate of the MouseEvent.
@@ -677,8 +682,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method is called to pass on the drag information
- * to the UI through dragDividerTo.
+ * This method is called to pass on the drag information to the UI
+ * through dragDividerTo.
*
* @param e The MouseEvent.
*/
@@ -689,8 +694,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method is called to finish the drag session
- * by calling finishDraggingTo.
+ * This method is called to finish the drag session by calling
+ * finishDraggingTo.
*
* @param x The x coordinate of the MouseEvent.
* @param y The y coordinate of the MouseEvent.
@@ -701,8 +706,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method is called to finish the drag session
- * by calling finishDraggingTo.
+ * This method is called to finish the drag session by calling
+ * finishDraggingTo.
*
* @param e The MouseEvent.
*/
@@ -710,10 +715,10 @@ public class BasicSplitPaneDivider extends Container
{
finishDraggingTo(positionForMouseEvent(e));
}
-
+
/**
- * This is a helper method that includes the offset
- * in the needed location.
+ * This is a helper method that includes the offset in the needed
+ * location.
*
* @param x The x coordinate of the MouseEvent.
* @param y The y coordinate of the MouseEvent.
@@ -727,8 +732,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This is a helper class that controls dragging when
- * the orientation is VERTICAL_SPLIT.
+ * This is a helper class that controls dragging when the orientation is
+ * VERTICAL_SPLIT.
*/
protected class VerticalDragController extends DragController
{
@@ -744,8 +749,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method returns one of the two parameters given
- * the orientation. In this case, it returns y.
+ * This method returns one of the two parameters given the orientation. In
+ * this case, it returns y.
*
* @param x The x coordinate of the MouseEvent.
* @param y The y coordinate of the MouseEvent.
@@ -758,8 +763,7 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method returns the new location of the divider
- * given a MouseEvent.
+ * This method returns the new location of the divider given a MouseEvent.
*
* @param e The MouseEvent.
*
@@ -771,8 +775,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This is a helper method that includes the offset
- * in the needed location.
+ * This is a helper method that includes the offset in the needed
+ * location.
*
* @param x The x coordinate of the MouseEvent.
* @param y The y coordinate of the MouseEvent.
@@ -782,12 +786,11 @@ public class BasicSplitPaneDivider extends Container
int adjust(int x, int y)
{
return getNeededLocation(x, y) + getY() - offset;
- }
+ }
}
/**
- * This helper class acts as the Layout Manager for
- * the divider.
+ * This helper class acts as the Layout Manager for the divider.
*/
protected class DividerLayout implements LayoutManager
{
@@ -858,8 +861,8 @@ public class BasicSplitPaneDivider extends Container
}
/**
- * This method changes the button orientation when
- * the orientation of the SplitPane changes.
+ * This method changes the button orientation when the orientation of the
+ * SplitPane changes.
*/
private void changeButtonOrientation()
{
diff --git a/libjava/javax/swing/plaf/basic/BasicSplitPaneUI.java b/libjava/javax/swing/plaf/basic/BasicSplitPaneUI.java
index f73b52045ba..fbcc1889630 100644
--- a/libjava/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -1,4 +1,4 @@
-/* BasicSplitPaneUI.java
+/* BasicSplitPaneUI.java --
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Canvas;
@@ -51,10 +52,9 @@ import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import javax.swing.JButton;
+
import javax.swing.JComponent;
import javax.swing.JSplitPane;
import javax.swing.KeyStroke;
@@ -63,7 +63,6 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SplitPaneUI;
-
/**
* This is the Basic Look and Feel implementation of the SplitPaneUI class.
*/
@@ -682,7 +681,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This is a deprecated class. It is supposed to be used for handling down
* and right key presses.
*/
- protected class KeyboardDownRightHandler implements ActionListener
+ public class KeyboardDownRightHandler implements ActionListener
{
/**
* This method is called when the down or right keys are pressed.
@@ -699,7 +698,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This is a deprecated class. It is supposed to be used for handling end
* key presses.
*/
- protected class KeyboardEndHandler implements ActionListener
+ public class KeyboardEndHandler implements ActionListener
{
/**
* This method is called when the end key is pressed.
@@ -716,7 +715,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This is a deprecated class. It is supposed to be used for handling home
* key presses.
*/
- protected class KeyboardHomeHandler implements ActionListener
+ public class KeyboardHomeHandler implements ActionListener
{
/**
* This method is called when the home key is pressed.
@@ -733,7 +732,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This is a deprecated class. It is supposed to be used for handling resize
* toggles.
*/
- protected class KeyboardResizeToggleHandler implements ActionListener
+ public class KeyboardResizeToggleHandler implements ActionListener
{
/**
* This method is called when a resize is toggled.
@@ -750,7 +749,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This is a deprecated class. It is supposed to be used for handler up and
* left key presses.
*/
- protected class KeyboardUpLeftHandler implements ActionListener
+ public class KeyboardUpLeftHandler implements ActionListener
{
/**
* This method is called when the left or up keys are pressed.
@@ -767,7 +766,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* This helper class handles PropertyChangeEvents from the JSplitPane. When
* a property changes, this will update the UI accordingly.
*/
- protected class PropertyHandler implements PropertyChangeListener
+ public class PropertyHandler implements PropertyChangeListener
{
/**
* This method is called whenever one of the JSplitPane's properties
@@ -846,43 +845,43 @@ public class BasicSplitPaneUI extends SplitPaneUI
/** The JSplitPane's focus handler. */
protected FocusListener focusListener;
- /** Deprecated. The handler for down and right key presses. */
+ /** @deprecated The handler for down and right key presses. */
protected ActionListener keyboardDownRightListener;
- /** Deprecated. The handler for end key presses. */
+ /** @deprecated The handler for end key presses. */
protected ActionListener keyboardEndListener;
- /** Deprecated. The handler for home key presses. */
+ /** @deprecated The handler for home key presses. */
protected ActionListener keyboardHomeListener;
- /** Deprecated. The handler for toggling resizes. */
+ /** @deprecated The handler for toggling resizes. */
protected ActionListener keyboardResizeToggleListener;
- /** Deprecated. The handler for up and left key presses. */
+ /** @deprecated The handler for up and left key presses. */
protected ActionListener keyboardUpLeftListener;
/** The JSplitPane's current layout manager. */
protected BasicHorizontalLayoutManager layoutManager;
- /** Deprecated. The divider resize toggle key. */
+ /** @deprecated The divider resize toggle key. */
protected KeyStroke dividerResizeToggleKey;
- /** Deprecated. The down key. */
+ /** @deprecated The down key. */
protected KeyStroke downKey;
- /** Deprecated. The end key. */
+ /** @deprecated The end key. */
protected KeyStroke endKey;
- /** Deprecated. The home key. */
+ /** @deprecated The home key. */
protected KeyStroke homeKey;
- /** Deprecated. The left key. */
+ /** @deprecated The left key. */
protected KeyStroke leftKey;
- /** Deprecated. The right key. */
+ /** @deprecated The right key. */
protected KeyStroke rightKey;
- /** Deprecated. The up key. */
+ /** @deprecated The up key. */
protected KeyStroke upKey;
/** Set to true when dragging heavy weight components. */
@@ -892,7 +891,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
* The constraints object used when adding the non-continuous divider to the
* JSplitPane.
*/
- protected static String NON_CONTINUOUS_DIVIDER;
+ protected static final String NON_CONTINUOUS_DIVIDER
+ = "nonContinuousDivider";
/** The dark divider used when dragging in non-continuous layout mode. */
protected Component nonContinuousLayoutDivider;
@@ -1042,10 +1042,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Deprecated. This method creates a new ActionListener for up and left key
- * presses.
+ * This method creates a new ActionListener for up and left key presses.
*
* @return A new ActionListener for up and left keys.
+ *
+ * @deprecated 1.3
*/
protected ActionListener createKeyboardUpLeftListener()
{
@@ -1053,10 +1054,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Deprecated. This method creates a new ActionListener for down and right
- * key presses.
+ * This method creates a new ActionListener for down and right key presses.
*
* @return A new ActionListener for down and right keys.
+ *
+ * @deprecated 1.3
*/
protected ActionListener createKeyboardDownRightListener()
{
@@ -1064,10 +1066,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Deprecated. This method creates a new ActionListener for home key
- * presses.
+ * This method creates a new ActionListener for home key presses.
*
* @return A new ActionListener for home keys.
+ *
+ * @deprecated
*/
protected ActionListener createKeyboardHomeListener()
{
@@ -1075,9 +1078,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Deprecated. This method creates a new ActionListener for end key presses.
+ * This method creates a new ActionListener for end key presses.i
*
* @return A new ActionListener for end keys.
+ *
+ * @deprecated 1.3
*/
protected ActionListener createKeyboardEndListener()
{
@@ -1085,10 +1090,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Depcreated. This method creates a new ActionListener for resize toggle
- * key events.
+ * This method creates a new ActionListener for resize toggle key events.
*
* @return A new ActionListener for resize toggle keys.
+ *
+ * @deprecated 1.3
*/
protected ActionListener createKeyboardResizeToggleListener()
{
@@ -1482,10 +1488,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
}
/**
- * Deprecated. This method returns the width of one of the sides of the
- * divider's border.
+ * This method returns the width of one of the sides of the divider's border.
*
* @return The width of one side of the divider's border.
+ *
+ * @deprecated 1.3
*/
protected int getDividerBorderSize()
{
diff --git a/libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 44e302b0188..7073086aae5 100644
--- a/libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -28,7 +28,7 @@ permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of7 the license of that
+independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
@@ -132,11 +132,17 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
if (++currentScrollLocation >= tabCount)
currentScrollLocation = tabCount - 1;
- if (currentScrollLocation == tabCount - 1)
- incrButton.setEnabled(false);
+
+ int width = 0;
+ for (int i = currentScrollLocation - 1; i < tabCount; i++)
+ width += rects[i].width;
+ if (width < viewport.getWidth())
+ // FIXME: Still getting mouse events after the button is disabled.
+ // incrButton.setEnabled(false);
+ currentScrollLocation--;
else if (! decrButton.isEnabled())
decrButton.setEnabled(true);
- tabPane.layout();
+ tabPane.revalidate();
tabPane.repaint();
return;
}
@@ -148,7 +154,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
decrButton.setEnabled(false);
else if (! incrButton.isEnabled())
incrButton.setEnabled(true);
- tabPane.layout();
+ tabPane.revalidate();
tabPane.repaint();
return;
}
@@ -160,7 +166,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// e.g. in the inset area.
if (index != -1 && tabPane.isEnabledAt(index))
tabPane.setSelectedIndex(index);
- tabPane.layout();
+ tabPane.revalidate();
tabPane.repaint();
}
}
@@ -168,7 +174,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/**
* This class handles PropertyChangeEvents fired from the JTabbedPane.
*/
- protected class PropertyChangeHandler implements PropertyChangeListener
+ public class PropertyChangeHandler implements PropertyChangeListener
{
/**
* This method is called whenever one of the properties of the JTabbedPane
@@ -269,18 +275,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
if (tabPlacement == SwingConstants.TOP
|| tabPlacement == SwingConstants.BOTTOM)
{
- width = calculateMaxTabWidth(tabPlacement) * tabPane.getTabCount();
- calcRect = tabPane.getParent().getBounds();
- width = Math.max(width, componentWidth);
+ int min = calculateMaxTabWidth(tabPlacement);
+ width = Math.max(min, componentWidth);
int tabAreaHeight = preferredTabAreaHeight(tabPlacement, width);
height = tabAreaHeight + componentHeight;
}
else
{
- height = calculateMaxTabHeight(tabPlacement) * tabPane.getTabCount();
- calcRect = tabPane.getParent().getBounds();
- height = Math.max(height, componentHeight);
+ int min = calculateMaxTabHeight(tabPlacement);
+ height = Math.max(min, componentHeight);
int tabAreaWidth = preferredTabAreaWidth(tabPlacement, height);
width = tabAreaWidth + componentWidth;
@@ -454,7 +458,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
for (int j = first; j <= last; j++)
rects[j].y += (runCount - i) * maxTabHeight
- + (runCount - i) * tabRunOverlay;
+ - (runCount - i) * tabRunOverlay;
}
if (tabPlacement == SwingConstants.BOTTOM)
@@ -810,7 +814,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void rotateTabRuns(int tabPlacement, int selectedRun)
{
- if (selectedRun == 1 || selectedRun == -1)
+ if (runCount == 1 || selectedRun == 1 || selectedRun == -1)
return;
int[] newTabRuns = new int[tabRuns.length];
int currentRun = selectedRun;
@@ -1025,6 +1029,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
super.layoutContainer(pane);
int tabCount = tabPane.getTabCount();
+ Point p = null;
if (tabCount == 0)
return;
int tabPlacement = tabPane.getTabPlacement();
@@ -1083,20 +1088,21 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
int w = Math.max(rects[tabC].width + rects[tabC].x, tabAreaRect.width);
int h = Math.max(rects[tabC].height, tabAreaRect.height);
- Point p = findPointForIndex(currentScrollLocation);
+ p = findPointForIndex(currentScrollLocation);
// we want to cover that entire space so that borders that run under
// the tab area don't show up when we move the viewport around.
panel.setSize(w + p.x, h + p.y);
}
- viewport.setViewPosition(findPointForIndex(currentScrollLocation));
+ viewport.setViewPosition(p);
+ viewport.repaint();
}
}
/**
* This class handles ChangeEvents from the JTabbedPane.
*/
- protected class TabSelectionHandler implements ChangeListener
+ public class TabSelectionHandler implements ChangeListener
{
/**
* This method is called whenever a ChangeEvent is fired from the
@@ -1257,16 +1263,32 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/** This array keeps track of which tabs are in which run. See above. */
protected int[] tabRuns;
- /** Deprecated. This is the keystroke for moving down. */
+ /**
+ * This is the keystroke for moving down.
+ *
+ * @deprecated 1.3
+ */
protected KeyStroke downKey;
- /** Deprecated. This is the keystroke for moving left. */
+ /**
+ * This is the keystroke for moving left.
+ *
+ * @deprecated 1.3
+ */
protected KeyStroke leftKey;
- /** Deprecated. This is the keystroke for moving right. */
+ /**
+ * This is the keystroke for moving right.
+ *
+ * @deprecated 1.3
+ */
protected KeyStroke rightKey;
- /** Deprecated. This is the keystroke for moving up. */
+ /**
+ * This is the keystroke for moving up.
+ *
+ * @deprecated 1.3
+ */
protected KeyStroke upKey;
/** The listener that listens for focus events. */
@@ -1446,6 +1468,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
incrButton = createIncreaseButton();
decrButton = createDecreaseButton();
viewport = new ScrollingViewport();
+ viewport.setLayout(null);
panel = new ScrollingPanel();
viewport.setView(panel);
tabPane.add(incrButton);
@@ -1690,6 +1713,8 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
Rectangle ir = new Rectangle();
Rectangle tr = new Rectangle();
+ boolean isScroll = tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT;
+
// Please note: the ordering of the painting is important.
// we WANT to paint the outermost run first and then work our way in.
int tabCount = tabPane.getTabCount();
@@ -1702,17 +1727,33 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
for (int i = 0; i < runCount; i++)
{
int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;
- if (first == tabCount)
+ if (isScroll)
+ first = currentScrollLocation;
+ else if (first == tabCount)
first = 0;
int last = lastTabInRun(tabCount, currRun);
+ if (isScroll)
+ {
+ for (int k = first; k < tabCount; k++)
+ {
+ if (rects[k].x + rects[k].width - rects[first].x > viewport
+ .getWidth())
+ {
+ last = k;
+ break;
+ }
+ }
+ }
+
for (int j = first; j <= last; j++)
{
- if (j != selectedIndex)
+ if (j != selectedIndex || isScroll)
paintTab(g, tabPlacement, rects, j, ir, tr);
}
- currRun = getNextTabRun(currRun);
+ currRun = getPreviousTabRun(currRun);
}
- paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
+ if (! isScroll)
+ paintTab(g, tabPlacement, rects, selectedIndex, ir, tr);
}
/**
@@ -1975,7 +2016,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int x, int y, int w, int h, boolean isSelected)
{
Color saved = g.getColor();
-
+
if (! isSelected || tabPlacement != SwingConstants.TOP)
{
g.setColor(shadow);
@@ -2030,7 +2071,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
Color bg = tabPane.getBackgroundAt(tabIndex);
if (bg == null)
- bg = tabPane.getBackground();
+ bg = Color.GRAY;
g.setColor(bg);
}
@@ -2083,14 +2124,14 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int diff = 0;
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.x;
- }
-
if (tabPlacement == SwingConstants.TOP)
{
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ {
+ Point p = findPointForIndex(currentScrollLocation);
+ diff = p.x;
+ }
+
g.drawLine(x, y, startgap - diff, y);
g.drawLine(endgap - diff, y, x + w, y);
}
@@ -2123,14 +2164,14 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int diff = 0;
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.y;
- }
-
if (tabPlacement == SwingConstants.LEFT)
{
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ {
+ Point p = findPointForIndex(currentScrollLocation);
+ diff = p.y;
+ }
+
g.drawLine(x, y, x, startgap - diff);
g.drawLine(x, endgap - diff, x, y + h);
}
@@ -2162,14 +2203,14 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int diff = 0;
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.x;
- }
-
if (tabPlacement == SwingConstants.BOTTOM)
{
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ {
+ Point p = findPointForIndex(currentScrollLocation);
+ diff = p.x;
+ }
+
g.setColor(shadow);
g.drawLine(x + 1, y + h - 1, startgap - diff, y + h - 1);
g.drawLine(endgap - diff, y + h - 1, x + w - 1, y + h - 1);
@@ -2209,14 +2250,15 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
int endgap = rects[selectedIndex].y + rects[selectedIndex].height;
int diff = 0;
- if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
- {
- Point p = findPointForIndex(currentScrollLocation);
- diff = p.y;
- }
if (tabPlacement == SwingConstants.RIGHT)
{
+ if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT)
+ {
+ Point p = findPointForIndex(currentScrollLocation);
+ diff = p.y;
+ }
+
g.setColor(shadow);
g.drawLine(x + w - 1, y + 1, x + w - 1, startgap - diff);
g.drawLine(x + w - 1, endgap - diff, x + w - 1, y + h - 1);
diff --git a/libjava/javax/swing/plaf/basic/BasicTableHeaderUI.java b/libjava/javax/swing/plaf/basic/BasicTableHeaderUI.java
index c55c9400fa2..ea7dfc0cd6d 100644
--- a/libjava/javax/swing/plaf/basic/BasicTableHeaderUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTableHeaderUI.java
@@ -1,4 +1,4 @@
-/* BasicTableHeaderUI.java
+/* BasicTableHeaderUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Component;
@@ -42,6 +43,7 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
+
import javax.swing.CellRendererPane;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
@@ -55,7 +57,6 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-
public class BasicTableHeaderUI
extends TableHeaderUI
{
@@ -180,84 +181,6 @@ public class BasicTableHeaderUI
}
}
-
- public Dimension getMaximumSize(JComponent c)
- {
- TableColumnModel cmod = header.getColumnModel();
- TableCellRenderer defaultRend = header.getDefaultRenderer();
- int ncols = cmod.getColumnCount();
- int spacing = 0;
- Dimension ret = getPreferredSize(c);
-
- if (header.getTable() != null
- && header.getTable().getInterCellSpacing() != null)
- spacing = header.getTable().getInterCellSpacing().width;
-
- ret.width = 0;
- for (int i = 0; i < ncols; ++i)
- {
- TableColumn col = cmod.getColumn(i);
- TableCellRenderer rend = col.getHeaderRenderer();
- if (rend == null)
- rend = defaultRend;
- Object val = col.getHeaderValue();
- Component comp = rend.getTableCellRendererComponent(header.getTable(),
- val,
- false, // isSelected
- false, // isFocused
- -1, i);
- comp.setFont(header.getFont());
- comp.setBackground(header.getBackground());
- comp.setForeground(header.getForeground());
- if (comp instanceof JComponent)
- ((JComponent)comp).setBorder(cellBorder);
-
- Dimension d = comp.getMaximumSize();
- ret.width += col.getMaxWidth();
- ret.height = Math.max(ret.height, d.height);
- ret.width += spacing;
- }
- return ret;
- }
-
- public Dimension getMinimumSize(JComponent c)
- {
- TableColumnModel cmod = header.getColumnModel();
- TableCellRenderer defaultRend = header.getDefaultRenderer();
- int ncols = cmod.getColumnCount();
- int spacing = 0;
- Dimension ret = getPreferredSize(c);
-
- if (header.getTable() != null
- && header.getTable().getInterCellSpacing() != null)
- spacing = header.getTable().getInterCellSpacing().width;
-
- ret.width = 0;
- for (int i = 0; i < ncols; ++i)
- {
- TableColumn col = cmod.getColumn(i);
- TableCellRenderer rend = col.getHeaderRenderer();
- if (rend == null)
- rend = defaultRend;
- Object val = col.getHeaderValue();
- Component comp = rend.getTableCellRendererComponent(header.getTable(),
- val,
- false, // isSelected
- false, // isFocused
- -1, i);
- comp.setFont(header.getFont());
- comp.setBackground(header.getBackground());
- comp.setForeground(header.getForeground());
- if (comp instanceof JComponent)
- ((JComponent)comp).setBorder(cellBorder);
-
- Dimension d = comp.getMinimumSize();
- ret.width += col.getMinWidth();
- ret.width += spacing;
- ret.height = Math.max(ret.height, d.height);
- }
- return ret;
- }
public Dimension getPreferredSize(JComponent c)
{
@@ -290,10 +213,10 @@ public class BasicTableHeaderUI
((JComponent)comp).setBorder(cellBorder);
Dimension d = comp.getPreferredSize();
- ret.width += d.width;
ret.width += spacing;
ret.height = Math.max(d.height, ret.height);
}
+ ret.width = cmod.getTotalColumnWidth();
return ret;
}
diff --git a/libjava/javax/swing/plaf/basic/BasicTableUI.java b/libjava/javax/swing/plaf/basic/BasicTableUI.java
index 5fa8fb71312..eb0054bb645 100644
--- a/libjava/javax/swing/plaf/basic/BasicTableUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTableUI.java
@@ -1,4 +1,4 @@
-/* BasicTableUI.java
+/* BasicTableUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -43,29 +44,28 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
+
import javax.swing.CellRendererPane;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TableUI;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
-
public class BasicTableUI
extends TableUI
{
-
public static ComponentUI createUI(JComponent comp)
{
return new BasicTableUI();
diff --git a/libjava/javax/swing/plaf/basic/BasicTextAreaUI.java b/libjava/javax/swing/plaf/basic/BasicTextAreaUI.java
index f1714c20d35..61d025ddd04 100644
--- a/libjava/javax/swing/plaf/basic/BasicTextAreaUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTextAreaUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.beans.PropertyChangeEvent;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
diff --git a/libjava/javax/swing/plaf/basic/BasicTextFieldUI.java b/libjava/javax/swing/plaf/basic/BasicTextFieldUI.java
index b43fd97cf07..e7cf33b1baf 100644
--- a/libjava/javax/swing/plaf/basic/BasicTextFieldUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTextFieldUI.java
@@ -41,11 +41,9 @@ package javax.swing.plaf.basic;
import java.beans.PropertyChangeEvent;
import javax.swing.JComponent;
-import javax.swing.JTextField;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.Element;
import javax.swing.text.FieldView;
-import javax.swing.text.PlainDocument;
import javax.swing.text.View;
public class BasicTextFieldUI extends BasicTextUI
diff --git a/libjava/javax/swing/plaf/basic/BasicTextPaneUI.java b/libjava/javax/swing/plaf/basic/BasicTextPaneUI.java
new file mode 100644
index 00000000000..615c74b2bff
--- /dev/null
+++ b/libjava/javax/swing/plaf/basic/BasicTextPaneUI.java
@@ -0,0 +1,69 @@
+/* BasicTextPaneUI.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.basic;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.text.Element;
+import javax.swing.text.PlainView;
+import javax.swing.text.View;
+
+public class BasicTextPaneUI extends BasicTextUI
+{
+ public static ComponentUI createUI(JComponent comp)
+ {
+ return new BasicTextPaneUI();
+ }
+
+ public BasicTextPaneUI()
+ {
+ }
+
+ public View create(Element elem)
+ {
+ return new PlainView(elem);
+ }
+
+ protected String getPropertyPrefix()
+ {
+ return "TextPane";
+ }
+}
diff --git a/libjava/javax/swing/plaf/basic/BasicTextUI.java b/libjava/javax/swing/plaf/basic/BasicTextUI.java
index 2ccf2fa5e08..b3d03dbae68 100644
--- a/libjava/javax/swing/plaf/basic/BasicTextUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTextUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -46,6 +45,8 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -56,7 +57,6 @@ import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
-import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
import javax.swing.text.BadLocationException;
@@ -70,7 +70,6 @@ import javax.swing.text.Element;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
-import javax.swing.text.PlainDocument;
import javax.swing.text.PlainView;
import javax.swing.text.Position;
import javax.swing.text.View;
@@ -231,9 +230,20 @@ public abstract class BasicTextUI extends TextUI
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
}
+ private FocusListener focuslistener = new FocusListener() {
+ public void focusGained(FocusEvent e)
+ {
+ textComponent.repaint();
+ }
+ public void focusLost(FocusEvent e)
+ {
+ textComponent.repaint();
+ }
+ };
+
protected void installListeners()
{
- // Do nothing here.
+ textComponent.addFocusListener(focuslistener);
}
protected String getKeymapName()
@@ -331,7 +341,7 @@ public abstract class BasicTextUI extends TextUI
protected void uninstallListeners()
{
- // Do nothing here.
+ textComponent.removeFocusListener(focuslistener);
}
protected void uninstallKeyboardActions()
@@ -370,7 +380,7 @@ public abstract class BasicTextUI extends TextUI
rootView.paint(g, getVisibleEditorRect());
- if (caret != null)
+ if (caret != null && textComponent.hasFocus())
caret.paint(g);
}
@@ -464,8 +474,17 @@ public abstract class BasicTextUI extends TextUI
protected void modelChanged()
{
+ if (textComponent == null || rootView == null)
+ return;
ViewFactory factory = rootView.getViewFactory();
- Element elem = textComponent.getDocument().getDefaultRootElement();
+ if (factory == null)
+ return;
+ Document doc = textComponent.getDocument();
+ if (doc == null)
+ return;
+ Element elem = doc.getDefaultRootElement();
+ if (elem == null)
+ return;
setView(factory.create(elem));
}
}
diff --git a/libjava/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java b/libjava/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
index f35968c6530..72554c0f45c 100644
--- a/libjava/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
@@ -1,4 +1,4 @@
-/* BasicToolBarSeparatorUI.java
+/* BasicToolBarSeparatorUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,22 +35,17 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
-import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.Insets;
-import java.awt.Rectangle;
+
import javax.swing.JComponent;
-import javax.swing.JToolBar.Separator;
import javax.swing.JSeparator;
-import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.SeparatorUI;
-
/**
* The Basic Look and Feel UI delegate for Separator.
diff --git a/libjava/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/javax/swing/plaf/basic/BasicToolBarUI.java
index 99e447501a5..8315fc05f09 100644
--- a/libjava/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -1,4 +1,4 @@
-/* BasicToolBarUI.java
+/* BasicToolBarUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,16 +35,15 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
-import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
@@ -53,15 +52,14 @@ import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.Enumeration;
import java.util.Hashtable;
+
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
@@ -74,13 +72,11 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.MouseInputListener;
-import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.BorderUIResource.EtchedBorderUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ToolBarUI;
import javax.swing.plaf.UIResource;
-
/**
* This is the Basic Look and Feel UI class for JToolBar.
*/
@@ -1331,10 +1327,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
private static class ToolBarBorder implements Border
{
/** The size of the larger, draggable side of the border. */
- private static int offset = 10;
+ private static final int offset = 10;
/** The other sides. */
- private static int regular = 2;
+ private static final int regular = 2;
/**
* This method returns the border insets for the JToolBar.
diff --git a/libjava/javax/swing/plaf/basic/BasicToolTipUI.java b/libjava/javax/swing/plaf/basic/BasicToolTipUI.java
index 3b5941f1bef..b561cce7174 100644
--- a/libjava/javax/swing/plaf/basic/BasicToolTipUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicToolTipUI.java
@@ -1,39 +1,40 @@
/* BasicToolTipUI.java --
Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
package javax.swing.plaf.basic;
@@ -44,6 +45,7 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+
import javax.swing.JComponent;
import javax.swing.JToolTip;
import javax.swing.SwingConstants;
@@ -54,7 +56,6 @@ import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ToolTipUI;
-
/**
* This is the Basic Look and Feel UI class for JToolTip.
*/
diff --git a/libjava/javax/swing/plaf/basic/BasicTreeUI.java b/libjava/javax/swing/plaf/basic/BasicTreeUI.java
index dac2f01601b..93e3900750a 100644
--- a/libjava/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicTreeUI.java
@@ -1,5 +1,5 @@
-/* BasicTreeUI.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* BasicTreeUI.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,11 +38,21 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
import javax.swing.JTree;
import javax.swing.plaf.TreeUI;
+import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreePath;
-
+import javax.swing.tree.TreeModel;
/**
* A delegate providing the user interface for <code>JTree</code>
@@ -57,6 +67,7 @@ import javax.swing.tree.TreePath;
public class BasicTreeUI
extends TreeUI
{
+
/**
* Determines the geometric extent of the label that is
* drawn for a path.
@@ -191,7 +202,6 @@ public class BasicTreeUI
return true; // FIXME: not implemented
}
-
/**
* Cancels editing a tree cell, discarding any entered value.
* If no editing session is active, nothing happens. The cell
@@ -233,4 +243,157 @@ public class BasicTreeUI
{
return null; // FIXME: not implemented
}
+
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicTreeUI();
+ }
+
+ int rightChildIndent;
+ int leftChildIndent;
+ int rowHeight;
+ Color hashColor;
+
+ protected void installDefaults(JTree tree)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ tree.setFont(defaults.getFont("Tree.font"));
+ tree.setForeground(defaults.getColor("Tree.foreground"));
+ tree.setBackground(defaults.getColor("Tree.background"));
+ tree.setOpaque(true);
+
+ hashColor = defaults.getColor("Tree.hash");
+ rightChildIndent = defaults.getInt("Tree.rightChildIndent");
+ leftChildIndent = defaults.getInt("Tree.leftChildIndent");
+ rowHeight = defaults.getInt("Tree.rowHeight");
+ }
+
+ protected void installKeyboardActions()
+ {
+ }
+
+ protected void installListeners()
+ {
+ }
+
+ public void installUI(JComponent c)
+ {
+ installDefaults((JTree) c);
+ }
+
+
+ protected void uninstallDefaults(JTree tree)
+ {
+ tree.setFont(null);
+ tree.setForeground(null);
+ tree.setBackground(null);
+
+ tree.setCellRenderer(null);
+ }
+
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults((JTree) c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return new Dimension(200,200);
+ }
+
+ protected void paintLeaf(Graphics g, int x, int y, JTree tree, Object leaf)
+ {
+ Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
+ leaf,
+ false, // selected
+ false, // expanded
+ true, // leaf
+ 0, // row
+ false // hasFocus
+ );
+ g.translate(x, y);
+ c.paint(g);
+ g.translate(-x, -y);
+ }
+
+ protected void paintNonLeaf(Graphics g, int x, int y, JTree tree, Object nonLeaf)
+ {
+ Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
+ nonLeaf,
+ false, // selected
+ false, // expanded
+ false, // leaf
+ 0, // row
+ false // hasFocus
+ );
+ g.translate(x, y);
+ c.paint(g);
+ g.translate(-x, -y);
+ }
+
+ protected int paintRecursive(Graphics g,
+ int indentation,
+ int descent,
+ int childNumber,
+ int depth,
+ JTree tree,
+ TreeModel mod,
+ Object curr)
+ {
+ Rectangle clip = g.getClipBounds();
+ if (indentation > clip.x + clip.width + rightChildIndent ||
+ descent > clip.y + clip.height + rowHeight)
+ return descent;
+
+
+ int halfHeight = rowHeight / 2;
+ int halfWidth = rightChildIndent / 2;
+ int y0 = descent + halfHeight;
+
+ if (mod.isLeaf(curr))
+ {
+ paintLeaf(g, indentation, descent, tree, curr);
+ descent += rowHeight;
+ }
+ else
+ {
+ if (depth > 0 || tree.isRootVisible())
+ {
+ paintNonLeaf(g, indentation, descent, tree, curr);
+ descent += rowHeight;
+ y0 += halfHeight;
+ }
+ int max = mod.getChildCount(curr);
+ for (int i = 0; i < max; ++i)
+ {
+ g.setColor(hashColor);
+ g.drawLine(indentation + halfWidth, descent + halfHeight,
+ indentation + rightChildIndent, descent + halfHeight);
+ descent = paintRecursive(g,
+ indentation + rightChildIndent, descent,
+ i, depth+1,
+ tree, mod, mod.getChild(curr, i));
+ }
+ }
+
+ int y1 = descent - halfHeight;
+ if (y0 != y1)
+ {
+ g.setColor(hashColor);
+ g.drawLine(indentation + halfWidth, y0,
+ indentation + halfWidth, y1);
+ }
+
+ return descent;
+ }
+
+ public void paint(Graphics g, JComponent c)
+ {
+ JTree tree = (JTree) c;
+ TreeModel mod = tree.getModel();
+ g.translate(10, 10);
+ paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());
+ g.translate(-10, -10);
+ }
}
diff --git a/libjava/javax/swing/plaf/basic/BasicViewportUI.java b/libjava/javax/swing/plaf/basic/BasicViewportUI.java
index feefacaae9b..1e0421b025f 100644
--- a/libjava/javax/swing/plaf/basic/BasicViewportUI.java
+++ b/libjava/javax/swing/plaf/basic/BasicViewportUI.java
@@ -1,4 +1,4 @@
-/* BasicViewportUI.java
+/* BasicViewportUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,6 +45,7 @@ import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;
+
import javax.swing.JComponent;
import javax.swing.JViewport;
import javax.swing.ViewportLayout;
@@ -119,17 +120,16 @@ public class BasicViewportUI extends ViewportUI
}
public void paint(Graphics g, JComponent c)
- {
-
- JViewport v = (JViewport)c;
- Component view = v.getView();
+ {
+ JViewport port = (JViewport)c;
+ Component view = port.getView();
if (view == null)
return;
- Point pos = v.getViewPosition();
+ Point pos = port.getViewPosition();
Rectangle viewBounds = view.getBounds();
- Rectangle portBounds = v.getBounds();
+ Rectangle portBounds = port.getBounds();
if (viewBounds.width == 0
|| viewBounds.height == 0
@@ -137,6 +137,51 @@ public class BasicViewportUI extends ViewportUI
|| portBounds.height == 0)
return;
+ switch (port.getScrollMode())
+ {
+
+ case JViewport.BACKINGSTORE_SCROLL_MODE:
+ paintBackingStore(g, port, view, pos, viewBounds, portBounds);
+ break;
+
+ case JViewport.BLIT_SCROLL_MODE:
+ // FIXME: implement separate blit mode
+
+ case JViewport.SIMPLE_SCROLL_MODE:
+ default:
+ paintSimple(g, port, view, pos, viewBounds, portBounds);
+ break;
+ }
+ }
+
+ private void paintSimple(Graphics g,
+ JViewport v,
+ Component view,
+ Point pos,
+ Rectangle viewBounds,
+ Rectangle portBounds)
+ {
+ Rectangle oldClip = g.getClipBounds ();
+ g.setClip (oldClip.intersection (viewBounds));
+ g.translate (-pos.x, -pos.y);
+ try
+ {
+ view.paint(g);
+ }
+ finally
+ {
+ g.translate (pos.x, pos.y);
+ g.setClip (oldClip);
+ }
+ }
+
+ private void paintBackingStore(Graphics g,
+ JViewport v,
+ Component view,
+ Point pos,
+ Rectangle viewBounds,
+ Rectangle portBounds)
+ {
if (backingStoreImage == null
|| backingStoreWidth != viewBounds.width
|| backingStoreHeight != viewBounds.height)
@@ -148,18 +193,17 @@ public class BasicViewportUI extends ViewportUI
Graphics g2 = backingStoreImage.getGraphics();
-
- if (c.getBackground() != null)
+ if (v.getBackground() != null)
{
// fill the backing store background
java.awt.Color save = g2.getColor();
- g2.setColor(c.getBackground());
+ g2.setColor(v.getBackground());
g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight);
g2.setColor(save);
// fill the viewport background
save = g.getColor();
- g.setColor(c.getBackground());
+ g.setColor(v.getBackground());
g.fillRect (0, 0, portBounds.width, portBounds.height);
g.setColor(save);
diff --git a/libjava/javax/swing/plaf/basic/ComboPopup.java b/libjava/javax/swing/plaf/basic/ComboPopup.java
index d4ef1f2e598..4cd518df5a5 100644
--- a/libjava/javax/swing/plaf/basic/ComboPopup.java
+++ b/libjava/javax/swing/plaf/basic/ComboPopup.java
@@ -1,4 +1,4 @@
-/* ComboPopup.java
+/* ComboPopup.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,14 +35,14 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.plaf.basic;
import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
-import javax.swing.JList;
+import javax.swing.JList;
public interface ComboPopup
{
diff --git a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
index 20becaf7ec8..fb6f27b88c1 100644
--- a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -43,7 +43,9 @@ import javax.swing.UIDefaults;
import javax.swing.plaf.basic.BasicLookAndFeel;
public class MetalLookAndFeel extends BasicLookAndFeel
- {
+{
+ private static final long serialVersionUID = 6680646159193457980L;
+
public boolean isNativeLookAndFeel() { return true; }
public boolean isSupportedLookAndFeel() { return true; }
public String getDescription() { return "Metal look and feel"; }
OpenPOWER on IntegriCloud