+2003-06-24 Michael Koch <konqueror@gmx.de>
+
+ * javax/swing/Timer.java,
+ javax/swing/plaf/ActionMapUIResource.java,
+ javax/swing/plaf/ButtonUI.java,
+ javax/swing/plaf/ColorChooserUI.java,
+ javax/swing/plaf/ColorUIResource.java,
+ javax/swing/plaf/ComboBoxUI.java,
+ javax/swing/plaf/ComponentInputMapUIResource.java,
+ javax/swing/plaf/basic/BasicBorders.java:
+ New versions from classpath.
+ * javax/swing/plaf/basic/BasicSplitPaneDivider.java.
+ javax/swing/plaf/basic/BasicSplitPaneUI.java:
+ New file from classpath.
+ * javax/swing/plaf/basic/doc-files/BasicBorders-1.png,
+ javax/swing/plaf/basic/doc-files/BasicBorders-2.png,
+ javax/swing/plaf/basic/doc-files/BasicBorders.FieldBorder-1.png,
+ javax/swing/plaf/doc-files/ComponentUI-1.dia,
+ javax/swing/plaf/doc-files/ComponentUI-1.png:
+ New binary files from classpath.
+
2003-06-24 Michael Koch <konqueror@gmx.de>
* java/io/LineNumberReader.java
public class Timer implements Serializable
{
+ protected EventListenerList listenerList = new EventListenerList();
+
int ticks;
static boolean verbose;
boolean running;
boolean repeat_ticks = true;
long interval, init_delay;
- Vector actions = new Vector();
class Waker extends Thread
{
public void addActionListener(ActionListener listener)
{
- actions.addElement(listener);
+ listenerList.add (ActionListener.class, listener);
}
+
public void removeActionListener(ActionListener listener)
{
- actions.removeElement(listener);
+ listenerList.remove (ActionListener.class, listener);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ return listenerList.getListeners (listenerType);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public ActionListener[] getActionListeners ()
+ {
+ return (ActionListener[]) listenerList.getListeners (ActionListener.class);
}
- void fireActionPerformed()
+ protected void fireActionPerformed (ActionEvent event)
{
- for (int i=0;i<actions.size();i++)
+ ActionListener[] listeners = getActionListeners();
+
+ for (int i = 0; i < listeners.length; i++)
{
- ActionListener a = (ActionListener) actions.elementAt(i);
- a.actionPerformed(new ActionEvent(this, ticks, "Timer"));
+ listeners [i].actionPerformed (event);
}
}
-
+ void fireActionPerformed ()
+ {
+ fireActionPerformed (new ActionEvent (this, ticks, "Timer"));
+ }
public static void setLogTimers(boolean flag)
{
/* ActionMapUIResource.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
package javax.swing.plaf;
-// Imports
-import javax.swing.*;
+import javax.swing.ActionMap;
+
/**
- * ActionMapUIResource
- * @author Andrew Selkirk
- * @version 1.0
+ * An <code>ActionMap</code> that implements the {@link UIResource}
+ * interface to indicate that it belongs to a pluggable
+ * LookAndFeel.
+ *
+ * @see javax.swing.ActionMap
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ActionMapUIResource extends ActionMap implements UIResource {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor ActionMapUIResource
- */
- public ActionMapUIResource() {
- // TODO
- } // ActionMapUIResource()
-
-
-} // ActionMapUIResource
+public class ActionMapUIResource
+ extends ActionMap
+ implements UIResource
+{
+ /**
+ * Constructs a new ActionMapUIResource.
+ */
+ public ActionMapUIResource()
+ {
+ /* The constructor does nothing. */
+ }
+}
/* ButtonUI.java
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
package javax.swing.plaf;
-public class ButtonUI extends ComponentUI
+/**
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JButton</code>.
+ *
+ * @see javax.swing.JButton
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+public abstract class ButtonUI
+ extends ComponentUI
{
}
/* ColorChooserUI.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
package javax.swing.plaf;
/**
- * ColorChooserUI
- * @author Andrew Selkirk
- * @version 1.0
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JColorChooser</code>.
+ *
+ * @see javax.swing.JColorChooser
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ColorChooserUI extends ComponentUI {
+public abstract class ColorChooserUI
+ extends ComponentUI
+{
+ /**
+ * Constructs a ColorChooserUI.
+ */
+ public ColorChooserUI()
+ {
+ /* The constructor does not do anything. */
+ }
+}
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor ColorChooserUI
- */
- public ColorChooserUI() {
- // TODO
- } // ColorChooserUI()
-
-
-} // ColorChooserUI
/* ColorUIResource.java
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
package javax.swing.plaf;
+
import java.awt.Color;
+
+
/**
- * STUBBED
+ * A Color that is marked as <code>UIResource</code>, which indicates that
+ * the color has been installed by a pluggable LookAndFeel. Such colors
+ * are replaced when the LookAndFeel changes.
+ *
+ * @see java.awt.Color
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ColorUIResource extends Color implements UIResource
+public class ColorUIResource
+ extends Color
+ implements UIResource
{
- public ColorUIResource(Color c)
+ /**
+ * Constructs a <code>ColorUIResource</code> using the specified
+ * red, green, and blue values, which must be given as integers in
+ * the range of 0-255. The alpha channel value will default to 255,
+ * meaning that the color is fully opaque.
+ *
+ * @param r the red intensity, which must be in the range [0 .. 255].
+ * @param g the green intensity, which must be in the range [0 .. 255].
+ * @param b the blue intensity, which must be in the range [0 .. 255].
+ */
+ public ColorUIResource(int r, int g, int b)
{
- super(c.getRGB());
+ super(r, g, b);
}
- public ColorUIResource(float r, float g, float b)
+
+
+ /**
+ * Consructs a <code>ColorUIResource</code> using the specified
+ * RGB value. The blue value is in bits 0-7, green in bits 8-15, and
+ * red in bits 16-23. The other bits are ignored. The alpha value is set
+ * to 255, meaning that the color is fully opaque.
+ *
+ * @param rgb the rgb value, as discussed above.
+ */
+ public ColorUIResource(int rgb)
{
- super(r, g, b, 1.0f);
+ super(rgb);
}
- public ColorUIResource(int rgb)
+
+
+ /**
+ * Constructs a <code>ColorUIResource</code> using the specified
+ * red, green, and blue intensities, which must be given as floats in
+ * the range of 0-1. The alpha channel value will default to 1.0f,
+ * meaning that the color is fully opaque.
+ *
+ * @param r the red intensity, which must be in the range [0.0 .. 1.0].
+ * @param g the green intensity, which must be in the range [0.0 .. 1.0].
+ * @param b the blue intensity, which must be in the range [0.0 .. 1.0].
+ */
+ public ColorUIResource(float r, float g, float b)
{
- super(rgb, false);
+ super(r, g, b);
}
- public ColorUIResource(int r, int g, int b)
+
+
+ /**
+ * Constructs a <code>ColorUIResource</code>, using the intensities
+ * of another color.
+ *
+ * @param c the color whose intensities will be considered when
+ * constructing this <code>ColorUIResource</code>.
+ */
+ public ColorUIResource(Color c)
{
- super(r, g, b, 255);
+ super(c.getRGB());
}
-} // class ColorUIResource
+}
package javax.swing.plaf;
-// Imports
-import javax.swing.*;
+import javax.swing.JComboBox;
/**
- * ComboBoxUI
- * @author Andrew Selkirk
- * @version 1.0
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JButton</code>.
+ *
+ * @see javax.swing.JComboBox
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ComboBoxUI extends ComponentUI {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor ComboBoxUI
- */
- public ComboBoxUI() {
- // TODO
- } // ComboBoxUI()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * setPopupVisible
- * @param combobox TODO
- * @param visible TODO
- */
- public abstract void setPopupVisible(JComboBox combobox, boolean visible);
-
- /**
- * isPopupVisible
- * @param combobox TODO
- * @returns boolean
- */
- public abstract boolean isPopupVisible(JComboBox combobox);
-
- /**
- * isFocusTraversable
- * @param combobox TODO
- * @returns boolean
- */
- public abstract boolean isFocusTraversable(JComboBox combobox);
-
-
-} // ComboBoxUI
+public abstract class ComboBoxUI
+ extends ComponentUI
+{
+ /**
+ * Constructs a new <code>ComboBoxUI</code>.
+ */
+ public ComboBoxUI()
+ {
+ }
+
+
+ /**
+ * Sets the visibility of the popup button.
+ *
+ * @param c the <code>JComboBox</code> whose popup
+ * is shown or hidden.
+ *
+ * @param visible <code>true</code> to show the popup, <code>false</code>
+ * to hide it.
+ */
+ public abstract void setPopupVisible(JComboBox c, boolean visible);
+
+
+ /**
+ * Determines whether the popup button is currently visible.
+ *
+ * @param c the <code>JComboBox</code> whose popup visibility
+ * is retrieved.
+ *
+ * @return <code>true</code> if the popup button is currently
+ * visible, <code>false</code> otherwise.
+ */
+ public abstract boolean isPopupVisible(JComboBox c);
+
+
+ /**
+ * Determines whether the combo box can receive input focus.
+ *
+ * @param c <code>JComboBox</code> whose focus traversability
+ * is to be retrieved.
+ *
+ * @returns <code>true</code> if <code>c</code> can receive
+ * input focus, <code>false</code> otherwise.
+ */
+ public abstract boolean isFocusTraversable(JComboBox c);
+}
/* ComponentInputMapUIResource.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
package javax.swing.plaf;
-// Imports
-import javax.swing.*;
+import javax.swing.ComponentInputMap;
+import javax.swing.JComponent;
+
/**
- * ComponentInputMapUIResource
- * @author Andrew Selkirk
- * @version 1.0
+ * A <code>ComponentInputMap</code> that implements the {@link UIResource}
+ * interface to indicate that it belongs to a pluggable
+ * LookAndFeel.
+ *
+ * @see javax.swing.ComponentInputMap
+ * @see javax.swing.InputMap
+ *
+ * @author Andrew Selkirk
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ComponentInputMapUIResource extends ComponentInputMap implements UIResource {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor ComponentInputMapUIResource
- * @param component TODO
- */
- public ComponentInputMapUIResource(JComponent component) {
- super(component);
- // TODO
- } // ComponentInputMapUIResource()
-
+public class ComponentInputMapUIResource
+ extends ComponentInputMap
+ implements UIResource
+{
+ /**
+ * Constructs a new <code>ComponentInputMapUIResource</code>.
+ *
+ * @param component the <code>JComponent</code> associated with
+ * this <code>InputMap</code>.
+ */
+ public ComponentInputMapUIResource(JComponent component)
+ {
+ super(component);
+ }
+}
-} // ComponentInputMapUIResource
import java.awt.Component;
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;
import javax.swing.JPopupMenu;
+import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.UIDefaults;
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.text.JTextComponent;
/**
{
UIDefaults defaults;
+ /* See comment in methods above for why this border is not shared. */
defaults = UIManager.getLookAndFeelDefaults();
return new MenuBarBorder(defaults.getColor("MenuBar.shadow"),
defaults.getColor("MenuBar.highlight"));
}
+ /**
+ * Returns a border for drawing a one-pixel thick border around
+ * split panes that are interrupted where the divider joins the
+ * border.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“SplitPane.darkShadow”</code> and
+ * <code>“SplitPane.highlight”</code>.
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * @return a {@link #SplitPaneBorder}.
+ *
+ * @see javax.swing.JSplitPane
+ * @see #getSplitPaneDividerBorder()
+ */
+ public static Border getSplitPaneBorder()
+ {
+ UIDefaults defaults;
+
+ /* See comment in methods above for why this border is not shared. */
+ defaults = UIManager.getLookAndFeelDefaults();
+ return new SplitPaneBorder(defaults.getColor("SplitPane.highlight"),
+ defaults.getColor("SplitPane.darkShadow"));
+ }
+
+
+ /**
+ * Returns a border for drawing a one-pixel thick border around
+ * the divider of split panes.
+ *
+ * <p>The colors of the edges that are adjacent to the child components
+ * of the <code>JSplitPane</code> are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“SplitPane.darkShadow”</code> and
+ * <code>“SplitPane.highlight”</code>. The color of the
+ * other two edges is the background color of the divider.
+ *
+ * <p><img src="BasicBorders.SplitPaneDividerBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * @return an instance of <code>SplitPaneDividerBorder</code>, which is
+ * not a public API class of this package.
+ *
+ * @see javax.swing.JSplitPane
+ * @see javax.swing.plaf.basic.BasicSplitPaneDivider
+ * @see #getSplitPaneBorder()
+ *
+ * @since 1.3
+ */
+ public static Border getSplitPaneDividerBorder()
+ {
+ UIDefaults defaults;
+
+ /* See comment in methods above for why this border is not shared. */
+ defaults = UIManager.getLookAndFeelDefaults();
+ return new SplitPaneDividerBorder(
+ defaults.getColor("SplitPane.highlight"),
+ defaults.getColor("SplitPane.darkShadow"));
+ }
+
+
+ /**
+ * Returns a border for drawing a border around a text field
+ * that makes the field appear as etched into the surface.
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“TextField.shadow”</code>,
+ * <code>“TextField.darkShadow”</code>,
+ * <code>“TextField.light”</code>, and
+ * <code>“TextField.highlight”</code>.
+ *
+ * <p><img src="BasicBorders.FieldBorder-1.png" width="500"
+ * height="200" alt="[A screen shot of a border returned by
+ * this method]" />
+ *
+ * @return an instance of
+ * {@link javax.swing.plaf.basic.BasicBorders$FieldBorder}.
+ *
+ * @see javax.swing.JTextField
+ * @see javax.swing.text.JTextComponent
+ */
+ public static Border getTextFieldBorder()
+ {
+ UIDefaults defaults;
+
+ /* See comment in methods above for why this border is not shared. */
+ defaults = UIManager.getLookAndFeelDefaults();
+ return new FieldBorder(
+ defaults.getColor("TextField.shadow"),
+ defaults.getColor("TextField.darkShadow"),
+ defaults.getColor("TextField.light"),
+ defaults.getColor("TextField.highlight"));
+ }
+
+
+ /**
+ * Returns a two-pixel thick, green
+ * <code>LineBorderUIResource</code>. This is so ugly that look and
+ * feels better use different borders for their progress bars, or
+ * they will look really terrible.
+ *
+ * <p><img src="BasicBorders-1.png" width="120" height="80"
+ * alt="[A screen shot of a border returned by this method]" />
+ */
+ public static Border getProgressBarBorder()
+ {
+ /* There does not seem to exist a way to parametrize the color
+ * or thickness of the border through UIDefaults.
+ */
+ return new BorderUIResource.LineBorderUIResource(Color.green, 2);
+ }
+
+
+ /**
+ * Returns a border that is composed of a raised bevel border and a
+ * one-pixel thick line border.
+ *
+ * <p><img src="BasicBorders-2.png" width="300" height="200"
+ * alt="[A screen shot of a border returned by this method]" />
+ *
+ * <p>The colors of the border are retrieved from the
+ * <code>UIDefaults</code> of the currently active look and feel
+ * using the keys <code>“InternalFrame.borderShadow”</code>,
+ * <code>“InternalFrame.borderDarkShadow”</code>,
+ * <code>“InternalFrame.borderLight”</code>,
+ * <code>“InternalFrame.borderHighlight”</code>, and
+ * (for the inner one-pixel thick line)
+ * <code>“InternalFrame.borderColor”</code>.
+ */
+ public static Border getInternalFrameBorder()
+ {
+ UIDefaults defaults;
+ Color shadow, darkShadow, highlight, lightHighlight, line;
+
+ /* See comment in methods above for why this border is not shared. */
+ defaults = UIManager.getLookAndFeelDefaults();
+
+ shadow = defaults.getColor("InternalFrame.borderShadow");
+ darkShadow = defaults.getColor("InternalFrame.borderDarkShadow");
+ highlight = defaults.getColor("InternalFrame.borderLight");
+ lightHighlight = defaults.getColor("InternalFrame.borderHighlight");
+ line = defaults.getColor("InternalFrame.borderColor");
+
+ return new BorderUIResource.CompoundBorderUIResource(
+ /* outer border */
+ new BorderUIResource.BevelBorderUIResource(
+ BevelBorder.RAISED,
+ (highlight != null) ? highlight : Color.lightGray,
+ (lightHighlight != null) ? lightHighlight : Color.white,
+ (darkShadow != null) ? darkShadow : Color.black,
+ (shadow != null) ? shadow : Color.gray),
+
+ /* inner border */
+ new BorderUIResource.LineBorderUIResource(
+ (line != null) ? line : Color.lightGray));
+ }
+
+
/**
* Returns a shared MarginBorder.
*/
}
+ /**
+ * A border that makes its enclosed component appear as lowered
+ * into the surface. Typically used for text fields.
+ *
+ * <p><img src="BasicBorders.FieldBorder-1.png" width="500"
+ * height="200" alt="[A screen shot of this border]" />
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
public static class FieldBorder
+ extends AbstractBorder
+ implements UIResource
{
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = 949220756998454908L;
+
+
+ /**
+ * The color for drawing the outer half of the top and left
+ * edges.
+ */
+ protected Color shadow;
+
+
+ /**
+ * The color for drawing the inner half of the top and left
+ * edges.
+ */
+ protected Color darkShadow;
+
+
+ /**
+ * The color for drawing the inner half of the bottom and right
+ * edges.
+ */
+ protected Color highlight;
+
+
+ /**
+ * The color for drawing the outer half of the bottom and right
+ * edges.
+ */
+ protected Color lightHighlight;
+
+
+ /**
+ * Constructs a new border for drawing a text field in the Basic
+ * look and feel.
+ *
+ * @param shadow the color for drawing the outer half
+ * of the top and left edges.
+ *
+ * @param darkShadow the color for drawing the inner half
+ * of the top and left edges.
+ *
+ * @param highlight the color for drawing the inner half
+ * of the bottom and right edges.
+ *
+ * @param lightHighlight the color for drawing the outer half
+ * of the bottom and right edges.
+ */
public FieldBorder(Color shadow, Color darkShadow,
Color highlight, Color lightHighlight)
{
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.gray;
+ this.darkShadow = (darkShadow != null) ? darkShadow : Color.black;
+ this.highlight = (highlight != null) ? highlight : Color.lightGray;
+ this.lightHighlight = (lightHighlight != null)
+ ? lightHighlight : Color.white;
+ }
+
+
+ /**
+ * Paints the FieldBorder around a given component.
+ *
+ * @param c the component whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ *
+ * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ BasicGraphicsUtils.drawEtchedRect(g, x, y, width, height,
+ shadow, darkShadow,
+ highlight, lightHighlight);
}
- } // class FieldBorder
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured.
+ * If <code>c</code> is an instance of {@link
+ * javax.swing.text.JTextComponent}, its margin is
+ * added to the border size.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+
+ /**
+ * Measures the width of this border, storing the results into a
+ * pre-existing Insets object.
+ *
+ * @param c the component whose border is to be measured.
+ * If <code>c</code> is an instance of {@link
+ * javax.swing.text.JTextComponent}, its margin is
+ * added to the border size.
+ *
+ * @param insets an Insets object for holding the result values.
+ * After invoking this method, the <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ *
+ * @return the same object that was passed for <code>insets</code>.
+ *
+ * @see #getBorderInsets()
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ if (insets == null)
+ insets = new Insets(2, 2, 2, 2);
+ else
+ insets.top = insets.left = insets.bottom = insets.right = 2;
+ if (c instanceof JTextComponent)
+ {
+ Insets margin = ((JTextComponent) c).getMargin();
+ insets.top += margin.top;
+ insets.left += margin.left;
+ insets.bottom += margin.bottom;
+ insets.right += margin.right;
+ }
+ return insets;
+ }
+ }
+
+
/**
* An invisible, but spacing border whose margin is determined
* by calling the <code>getMargin()</code> method of the enclosed
* determine the existence of this method, this would be slow on
* many virtual machines. Therefore, the current implementation
* knows about {@link javax.swing.AbstractButton#getMargin()},
- * {@link javax.swing.JPopupMenu#getMargin()}, and {@link
- * javax.swing.JToolBar#getMargin()}. If <code>c</code> is an
+ * {@link javax.swing.JPopupMenu#getMargin()}, {@link
+ * javax.swing.JToolBar#getMargin()}, and {@link
+ * javax.swing.text.JTextComponent}. If <code>c</code> is an
* instance of a known class, the respective
* <code>getMargin()</code> method is called to determine the
* correct margin. Otherwise, a zero-width margin is returned.
margin = ((JPopupMenu) c).getMargin();
else if (c instanceof JToolBar)
margin = ((JToolBar) c).getMargin();
-
+ else if (c instanceof JTextComponent)
+ margin = ((JTextComponent) c).getMargin();
+
if (margin == null)
insets.top = insets.left = insets.bottom = insets.right = 0;
else
}
+ /**
+ * A one-pixel thick border for rollover buttons, for example in
+ * tool bars.
+ *
+ * @since 1.4
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
public static class RolloverButtonBorder
+ extends ButtonBorder
{
- } // class RolloverButtonBorder
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Sun JDK 1.4.1_01 on GNU/Linux 2.4.20 for x86.
+ */
+ static final long serialVersionUID = 1976364864896996846L;
+
+
+ /**
+ * Constructs a new border for drawing a roll-over button
+ * in the Basic look and feel.
+ *
+ * @param shadow the shadow color.
+ * @param darkShadow a darker variant of the shadow color.
+ * @param highlight the highlight color.
+ * @param lightHighlight a brighter variant of the highlight color.
+ */
+ public RolloverButtonBorder(Color shadow, Color darkShadow,
+ Color highlight, Color lightHighlight)
+ {
+ super(shadow, darkShadow, highlight, lightHighlight);
+ }
+
+
+ /**
+ * Paints the border around a rollover button. If <code>c</code>
+ * is not an {@link javax.swing.AbstractButton} whose model
+ * returns <code>true</code> for {@link
+ * javax.swing.ButtonModel#isRollver}, nothing gets painted at
+ * all.
+ *
+ * @param c the button whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ ButtonModel bmodel = null;
+ boolean drawPressed;
+ Color oldColor = g.getColor();
+ int x2, y2;
+
+ if (c instanceof AbstractButton)
+ bmodel = ((AbstractButton) c).getModel();
+
+ /* Draw nothing if c is not a rollover button. */
+ if ((bmodel == null) || !bmodel.isRollover())
+ return;
+
+ /* Draw nothing if the mouse is pressed, but outside the button. */
+ if (bmodel.isPressed() && !bmodel.isArmed())
+ return;
+
+ drawPressed = bmodel.isSelected() || bmodel.isPressed();
+ x2 = x + width - 1;
+ y2 = y + height - 1;
+
+ try
+ {
+ g.setColor(drawPressed ? shadow : lightHighlight);
+ g.drawLine(x, y, x2 - 1, y); // top edge
+ g.drawLine(x, y + 1, x, y2 - 1); // left edge
+
+ g.setColor(drawPressed ? lightHighlight : shadow);
+ g.drawLine(x, y2, x2, y2); // bottom edge
+ g.drawLine(x2, y, x2, y2 - 1); // right edge
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+ }
+
+
+ /**
+ * A border for JSplitPanes in the Basic look and feel. The divider
+ * in the middle of the JSplitPane has its own border class, of which
+ * an instance can be obtained with {@link #getSplitPaneDividerBorder()}.
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * <p>In contrast to the other borders of the Basic look and feel,
+ * this class is not serializable. While this might be unintended,
+ * GNU Classpath follows the specification in order to be fully
+ * compatible with the Sun reference implementation.
+ *
+ * <p>In the Sun JDK, the bottom edge of the divider also gets
+ * painted if the orientation of the enclosed JSplitPane is
+ * <code>JSplitPane.VERTICAL_SPLIT</code> (at least in versions
+ * 1.3.1 and 1.4.1). GNU Classpath does not replicate this bug. A
+ * report has been filed with Sun (review ID 188773).
+ *
+ * <p>Note that the bottom left pixel of the border has a different
+ * color depending on the orientation of the enclosed JSplitPane.
+ * Although this is visually inconsistent, Classpath replicates the
+ * appearance of the Sun reference implementation. A bug report has
+ * been filed with Sun (review ID 188774).
+ *
+ * @see {@link #getSplitPaneBorder()}
+ * @see {@link #getSplitPaneDividerBorder()}
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
public static class SplitPaneBorder
+ implements Border, UIResource
{
+ /**
+ * Indicates that the top edge shall be not be painted
+ * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ */
+ private static final int SUPPRESS_TOP = 1;
+
+
+ /**
+ * Indicates that the left edge shall be not be painted
+ * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ */
+ private static final int SUPPRESS_LEFT = 2;
+
+
+ /**
+ * Indicates that the bottom edge shall be not be painted
+ * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ */
+ private static final int SUPPRESS_BOTTOM = 4;
+
+
+ /**
+ * Indicates that the right edge shall be not be painted
+ * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ */
+ private static final int SUPPRESS_RIGHT = 8;
+
+
+ /**
+ * The color for drawing the bottom and right edges of the border.
+ */
+ protected Color highlight;
+
+
+ /**
+ * The color for drawing the top and left edges of the border.
+ */
+ protected Color shadow;
+
+
+ /**
+ * Constructs a new border for drawing a JSplitPane in the Basic
+ * look and feel. The divider in the middle of the JSplitPane has
+ * its own border class, <code>SplitPaneDividerBorder</code>.
+ *
+ * @param shadow the shadow color.
+ * @param highlight the highlight color.
+ */
public SplitPaneBorder(Color highlight, Color shadow)
{
+ /* These colors usually come from the UIDefaults of the current
+ * look and feel. Use fallback values if the colors are not
+ * supplied. The API specification is silent about what
+ * behavior is expected for null colors, so users should not
+ * rely on this fallback (which is why it is not documented in
+ * the above Javadoc).
+ */
+ this.shadow = (shadow != null) ? shadow : Color.black;
+ this.highlight = (highlight != null) ? highlight : Color.white;
+ }
+
+
+ /**
+ * Paints the border around a <code>JSplitPane</code>.
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-1.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.HORIZONTAL_SPLIT]" />
+ *
+ * <p><img src="BasicBorders.SplitPaneBorder-2.png" width="520"
+ * height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
+ *
+ * @param c the <code>JSplitPane</code> whose border is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ JSplitPane splitPane;
+ Component content;
+
+ if (!(c instanceof JSplitPane))
+ return;
+
+ splitPane = (JSplitPane) c;
+ switch (splitPane.getOrientation())
+ {
+ case JSplitPane.HORIZONTAL_SPLIT:
+ if ((content = splitPane.getLeftComponent()) != null)
+ paintRect(g, SUPPRESS_RIGHT, true, x, y, content.getBounds());
+ if ((content = splitPane.getRightComponent()) != null)
+ paintRect(g, SUPPRESS_LEFT, true, x, y, content.getBounds());
+ break;
+
+ case JSplitPane.VERTICAL_SPLIT:
+ if ((content = splitPane.getTopComponent()) != null)
+ paintRect(g, SUPPRESS_BOTTOM, false, x, y, content.getBounds());
+ if ((content = splitPane.getBottomComponent()) != null)
+ paintRect(g, SUPPRESS_TOP, false, x, y, content.getBounds());
+ break;
+ }
+ }
+
+
+ /**
+ * Paints a border around a child of a <code>JSplitPane</code>,
+ * omitting some of the edges.
+ *
+ * @param g the graphics for painting.
+ *
+ * @param suppress a bit mask indicating the set of suppressed
+ * edges, for example <code>SUPPRESS_TOP | SUPPRESS_RIGHT</code>.
+ *
+ * @param x the x coordinate of the SplitPaneBorder.
+ *
+ * @param y the y coordinate of the SplitPaneBorder.
+ *
+ * @param shadeBottomLeftPixel <code>true</code> to paint the
+ * bottom left pixel in the shadow color,
+ * <code>false</code> for the highlight color. The Basic
+ * look and feel uses the highlight color for the bottom
+ * left pixel of the border of a JSplitPane whose
+ * orientation is VERTICAL_SPLIT, and the shadow color
+ * otherwise. While this might be a strange distinction,
+ * Classpath tries to look identical to the reference
+ * implementation. A bug report has been filed with Sun;
+ * its review ID is 188774. We currently replicate the
+ * Sun behavior.
+ *
+ * @param rect the bounds of the child of JSplitPane whose
+ * border is to be painted.
+ */
+ private void paintRect(Graphics g, int suppress,
+ boolean shadeBottomLeftPixel,
+ int x, int y,
+ Rectangle rect)
+ {
+ if (rect == null)
+ return;
+
+ /* On each edge, the border exceeds the enclosed child by one
+ * pixel. See the image "BasicBorders.SplitPaneBorder-1.png" in
+ * the directory "doc-files".
+ */
+ x += rect.x - 1;
+ y += rect.y - 1;
+ int right = x + rect.width + 1;
+ int bottom = y + rect.height + 1;
+
+ Color oldColor = g.getColor();
+ try
+ {
+ g.setColor(shadow);
+ if ((suppress & SUPPRESS_TOP) == 0)
+ g.drawLine(x, y, right, y);
+ if ((suppress & SUPPRESS_LEFT) == 0)
+ g.drawLine(x, y, x, bottom);
+ else
+ g.drawLine(x, bottom, x, bottom); // one pixel
+
+ g.setColor(highlight);
+ if ((suppress & SUPPRESS_BOTTOM) == 0)
+ g.drawLine(x + (shadeBottomLeftPixel ? 1 : 0), bottom, right, bottom);
+ else if (!shadeBottomLeftPixel)
+ g.drawLine(x, bottom, x, bottom); // one pixel
+
+ if ((suppress & SUPPRESS_RIGHT) == 0)
+ g.drawLine(right, y, right, bottom);
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
+ }
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured, usually
+ * an instance of {@link javax.swing.JSplitPane}.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(1, 1, 1, 1);
+ }
+
+
+ /**
+ * Determines whether this border fills every pixel in its area
+ * when painting.
+ *
+ * @return <code>false</code> because this border does not
+ * paint over the pixels where the divider joins
+ * the border.
+ */
+ public boolean isBorderOpaque()
+ {
+ /* Strangely, the Sun implementation (tested with JDK 1.3.1 and
+ * 1.4.1_01) seems to always return true. It could be a bug,
+ * but without knowing the details of their implementation, it is
+ * hard to decide.
+ */
+ return false;
+ }
+ }
+
+
+ /**
+ * A border for the divider inside a JSplitPane.
+ *
+ * <p><img src="BasicBorders.SplitPaneDividerBorder-1.png"
+ * width="520" height="200" alt="[A screen shot of this border]" />
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+ private static class SplitPaneDividerBorder
+ implements Border, UIResource, Serializable
+ {
+ /**
+ * The highlight color, which is drawn on the left or top edge
+ * depending on the orientation of the JSplitPanel.
+ */
+ protected Color highlight;
+
+
+ /**
+ * The highlight color, which is drawn on the right or bottom edge
+ * depending on the orientation of the JSplitPanel.
+ */
+ protected Color shadow;
+
+
+ /**
+ * Constructs a new border for drawing the divider of a JSplitPane
+ * in the Basic look and feel. The outer parts of the JSplitPane have
+ * their own border class, <code>SplitPaneBorder</code>.
+ *
+ * @param shadow the shadow color.
+ * @param highlight the highlight color.
+ */
+ public SplitPaneDividerBorder(Color highlight, Color shadow)
+ {
+ this.highlight = (highlight != null) ? highlight : Color.white;
+ this.shadow = (shadow != null) ? shadow : Color.black;
+ }
+
+
+ /**
+ * Paints the border around the divider of a <code>JSplitPane</code>.
+ *
+ * <p><img src="BasicBorders.SplitPaneDividerBorder-1.png" width="520"
+ * height="200" alt="[A picture that shows which pixels get painted
+ * in what color]" />
+ *
+ * @param c the <code>JSplitPane</code> whose divider’s border
+ * is to be painted.
+ * @param g the graphics for painting.
+ * @param x the horizontal position for painting the border.
+ * @param y the vertical position for painting the border.
+ * @param width the width of the available area for painting the border.
+ * @param height the height of the available area for painting the border.
+ */
+ public void paintBorder(Component c, Graphics g,
+ int x, int y, int width, int height)
+ {
+ Color oldColor, dcol;
+ int x2, y2;
+ JSplitPane sp;
+
+ sp = getSplitPane(c);
+ if (sp == null)
+ return;
+
+ x2 = x + width - 1;
+ y2 = y + height - 1;
+ oldColor = g.getColor();
+ dcol = c.getBackground();
+ try
+ {
+ switch (sp.getOrientation())
+ {
+ case JSplitPane.HORIZONTAL_SPLIT:
+ g.setColor(dcol);
+ g.drawLine(x + 1, y, x2 - 1, y);
+ g.drawLine(x + 1, y2, x2 - 1, y2);
+ g.setColor(sp.getLeftComponent() != null ? highlight : dcol);
+ g.drawLine(x, y, x, y2);
+ g.setColor(sp.getRightComponent() != null ? shadow : dcol);
+ g.drawLine(x2, y, x2, y2);
+ break;
+
+ case JSplitPane.VERTICAL_SPLIT:
+ g.setColor(dcol);
+ g.drawLine(x, y + 1, x, y2 - 1);
+ g.drawLine(x2, y + 1, x2, y2 - 1);
+ g.setColor(sp.getTopComponent() != null ? highlight : dcol);
+ g.drawLine(x, y, x2, y);
+ g.setColor(sp.getBottomComponent() != null ? shadow : dcol);
+ g.drawLine(x, y2, x2, y2);
+ break;
+ }
+ }
+ finally
+ {
+ g.setColor(oldColor);
+ }
}
- } // class SplitPaneBorder
+
+
+ /**
+ * Measures the width of this border.
+ *
+ * @param c the component whose border is to be measured, usually
+ * an instance of {@link javax.swing.JSplitPane}.
+ *
+ * @return an Insets object whose <code>left</code>,
+ * <code>right</code>, <code>top</code> and
+ * <code>bottom</code> fields indicate the width of the
+ * border at the respective edge.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return new Insets(1, 1, 1, 1);
+ }
+
+
+ /**
+ * Determines whether this border fills every pixel in its area
+ * when painting.
+ *
+ * @return <code>true</code> if both highlight and shadow
+ * color are fully opaque.
+ */
+ public boolean isBorderOpaque()
+ {
+ return (highlight.getAlpha() == 255) && (shadow.getAlpha() == 255);
+ }
+
+
+ /**
+ * Determines the JSplitPane whose divider is being painted.
+ *
+ * @param c an instance of BasicSplitPaneDivider.
+ *
+ * @return a <code>JSplitPane</code>, or <code>null</code> if
+ * <code>c</code> is not an instance of {@link
+ * javax.swing.plaf.basic.BasicSplitPaneDivider}.
+ */
+ private JSplitPane getSplitPane(Component c)
+ {
+ if (c instanceof BasicSplitPaneDivider)
+ return (((BasicSplitPaneDivider) c).getBasicSplitPaneUI())
+ .getSplitPane();
+ else
+ return null;
+ }
+ }
/**
--- /dev/null
+/* BasicSplitPaneDivider.java
+ Copyright (C) 2003 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.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.event.MouseAdapter;
+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.border.Border;
+
+
+/**
+ * The divider that separates the two parts of a JSplitPane in the
+ * Basic look and feel.
+ *
+ * <p>Implementation status: We do not have a real implementation yet.
+ * Currently, it is mostly a stub to allow compiling other parts of
+ * the javax.swing.plaf.basic package, although some parts are already
+ * functional.
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+public class BasicSplitPaneDivider
+ extends Container
+ implements PropertyChangeListener
+{
+ /**
+ * Determined using the <code>serialver</code> tool
+ * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
+ */
+ static final long serialVersionUID = 1463404307042803342L;
+
+
+ /**
+ * The width and height of the little buttons for showing and
+ * hiding parts of a JSplitPane in a single mouse click.
+ */
+ protected static final int ONE_TOUCH_SIZE = 6;
+
+
+ // FIXME: Javadoc.
+ protected static final int ONE_TOUCH_OFFSET = 2;
+
+
+ /**
+ * An object that performs the tasks associated with an ongoing drag
+ * operation, or <code>null</code> if the user is currently not
+ * dragging the divider.
+ */
+ protected DragController dragger;
+
+
+ /**
+ * The delegate object that is responsible for the UI of the
+ * <code>JSplitPane</code> that contains this divider.
+ */
+ protected BasicSplitPaneUI splitPaneUI;
+
+
+ /**
+ * The thickness of the divider in pixels.
+ */
+ protected int dividerSize;
+
+
+ /**
+ * A divider that is used for layout purposes.
+ */
+ protected Component hiddenDivider;
+
+
+ /**
+ * The JSplitPane containing this divider.
+ */
+ protected JSplitPane splitPane;
+
+
+ /**
+ * The listener for handling mouse events from both the divider
+ * and the containing <code>JSplitPane</code>.
+ *
+ * <p>The reason for also handling MouseEvents from the containing
+ * <code>JSplitPane</code> is that users should be able to start
+ * a drag gesture from inside the JSplitPane, but slightly outisde
+ * the divider.
+ */
+ protected MouseHandler mouseHandler = new MouseHandler();
+
+
+ /**
+ * The current orientation of the containing <code>JSplitPane</code>,
+ * which is either {@link javax.swing.JSplitPane#HORIZONTAL_SPLIT}
+ * or {@link javax.swing.JSplitPane#VERTICAL_SPLIT}.
+ */
+ protected int orientation;
+
+
+ /**
+ * The button for showing and hiding the left (or top) component
+ * of the <code>JSplitPane</code>.
+ */
+ protected JButton leftButton;
+
+
+ /**
+ * The button for showing and hiding the right (or bottom) component
+ * of the <code>JSplitPane</code>.
+ */
+ protected JButton rightButton;
+
+
+ /**
+ * The border of this divider. Typically, this will be an instance of
+ * {@link javax.swing.plaf.basic.BasicBorders.SplitPaneDividerBorder}.
+ *
+ * @see #getBorder()
+ * @see #setBorder(javax.swing.border.Border)
+ */
+ private Border border;
+
+
+ /**
+ * Constructs a new divider.
+ *
+ * @param ui the UI delegate of the enclosing
+ * <code>JSplitPane</code>.
+ */
+ public BasicSplitPaneDivider(BasicSplitPaneUI ui)
+ {
+ setBasicSplitPaneUI(ui);
+ }
+
+
+ /**
+ * Sets the delegate object that is responsible for the UI of the
+ * {@link javax.swing.JSplitPane} containing this divider.
+ *
+ * @param newUI the UI delegate, or <code>null</code> to release
+ * the connection to the current delegate.
+ */
+ public void setBasicSplitPaneUI(BasicSplitPaneUI newUI)
+ {
+ /* Remove the connection to the existing JSplitPane. */
+ if (splitPane != null)
+ {
+ splitPane.removePropertyChangeListener(this);
+ splitPane.removeMouseListener(mouseHandler);
+ splitPane.removeMouseMotionListener(mouseHandler);
+ splitPane = null;
+ }
+
+ /* Establish the connection to the new JSplitPane. */
+ splitPaneUI = newUI;
+ if (splitPaneUI != null)
+ splitPane = newUI.getSplitPane();
+ if (splitPane != null)
+ {
+ splitPane.addPropertyChangeListener(this);
+ splitPane.addMouseListener(mouseHandler);
+ splitPane.addMouseMotionListener(mouseHandler);
+ orientation = splitPane.getOrientation();
+ }
+ }
+
+
+ /**
+ * Returns the delegate object that is responsible for the UI of the
+ * {@link javax.swing.JSplitPane} containing this divider.
+ */
+ public BasicSplitPaneUI getBasicSplitPaneUI()
+ {
+ return splitPaneUI;
+ }
+
+
+ /**
+ * Sets the thickness of the divider.
+ *
+ * @param newSize the new width or height in pixels.
+ */
+ public void setDividerSize(int newSize)
+ {
+ this.dividerSize = newSize;
+ }
+
+
+ /**
+ * Retrieves the thickness of the divider.
+ */
+ public int getDividerSize()
+ {
+ return dividerSize;
+ }
+
+
+ /**
+ * Sets the border of this divider.
+ *
+ * @param border the new border. Typically, this will be an instance of
+ * {@link javax.swing.plaf.basic.BasicBorders.SplitPaneDividerBorder}.
+ *
+ * @since 1.3
+ */
+ public void setBorder(Border border)
+ {
+ Border oldValue = this.border;
+ this.border = border;
+ firePropertyChange("border", oldValue, border);
+ }
+
+
+ /**
+ * Retrieves the border of this divider.
+ *
+ * @return the current border, or <code>null</code> if no border
+ * has been set.
+ *
+ * @since 1.3
+ */
+ public Border getBorder()
+ {
+ return border;
+ }
+
+
+ /**
+ * Retrieves the insets of the divider. If a border has been
+ * installed on the divider, the result of calling its
+ * <code>getBorderInsets</code> method is returned. Otherwise,
+ * the inherited implementation will be invoked.
+ *
+ * @see javax.swing.border.Border#getBorderInsets(java.awt.Component)
+ */
+ public Insets getInsets()
+ {
+ if (border != null)
+ return border.getBorderInsets(this);
+ else
+ return super.getInsets();
+ }
+
+
+ /**
+ * Returns the preferred size of this divider, which is
+ * <code>dividerSize</code> by <code>dividerSize</code>
+ * pixels.
+ */
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(dividerSize, dividerSize);
+ }
+
+
+ /**
+ * Returns the minimal size of this divider, which is
+ * <code>dividerSize</code> by <code>dividerSize</code>
+ * pixels.
+ */
+ public Dimension getMinimumSize()
+ {
+ return getPreferredSize();
+ }
+
+
+ /**
+ * Processes events from the <code>JSplitPane</code> that contains
+ * this divider.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ // FIXME: Not yet implemented.
+ }
+
+
+ /**
+ * Paints the divider by painting its border.
+ */
+ public void paint(Graphics g)
+ {
+ Dimension dividerSize;
+
+ super.paint(g);
+ if (border != null)
+ {
+ dividerSize = getSize();
+ border.paintBorder(this, g, 0, 0, dividerSize.width, dividerSize.height);
+ //System.out.println(dividerSize);
+ //g.setColor(java.awt.Color.white);
+ //g.drawRect(0, 0, 5, 5);
+ }
+ }
+
+
+ /**
+ * Reacts to changes of the <code>oneToughExpandable</code>
+ * property of the containing <code>JSplitPane</code>.
+ */
+ protected void oneTouchExpandableChanged()
+ {
+ // FIXME: Not yet implemented.
+ }
+
+
+ /**
+ * Creates a button for showing and hiding the left (or top)
+ * part of a <code>JSplitPane</code>.
+ */
+ protected JButton createLeftOneTouchButton()
+ {
+ return new OneTouchButton(/* left */ true);
+ }
+
+
+ /**
+ * Creates a button for showing and hiding the right (or bottom)
+ * part of a <code>JSplitPane</code>.
+ */
+ protected JButton createRightOneTouchButton()
+ {
+ return new OneTouchButton(/* left */ false);
+ }
+
+
+ /**
+ * Prepares the divider for dragging by calling the
+ * <code>startDragging</code> method of the UI delegate of the
+ * enclosing <code>JSplitPane</code>.
+ *
+ * @see BasicSplitPaneUI#startDragging()
+ */
+ protected void prepareForDragging()
+ {
+ if (splitPaneUI != null)
+ splitPaneUI.startDragging();
+ }
+
+
+ /**
+ * Drags the divider to a given location by calling the
+ * <code>dragDividerTo</code> method of the UI delegate of the
+ * enclosing <code>JSplitPane</code>.
+ *
+ * @param location the new location of the divider.
+ *
+ * @see BasicSplitPaneUI#dragDividerTo(int location)
+ */
+ protected void dragDividerTo(int location)
+ {
+ if (splitPaneUI != null)
+ splitPaneUI.dragDividerTo(location);
+ }
+
+
+ /**
+ * Finishes a dragging gesture by calling the
+ * <code>finishDraggingTo</code> method of the UI delegate of the
+ * enclosing <code>JSplitPane</code>.
+ *
+ * @param location the new, final location of the divider.
+ *
+ * @see BasicSplitPaneUI#finishDraggingTo(int location)
+ */
+ protected void finishDraggingTo(int location)
+ {
+ if (splitPaneUI != null)
+ splitPaneUI.finishDraggingTo(location);
+ }
+
+
+ /**
+ * The listener for handling mouse events from both the divider
+ * and the containing <code>JSplitPane</code>.
+ *
+ * <p>The reason for also handling MouseEvents from the containing
+ * <code>JSplitPane</code> is that users should be able to start
+ * a drag gesture from inside the JSplitPane, but slightly outisde
+ * the divider.
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+ protected class MouseHandler
+ extends MouseAdapter
+ implements MouseMotionListener
+ {
+
+ public void mousePressed(MouseEvent e)
+ {
+ // FIXME: Not yet implemented.
+ }
+
+
+ public void mouseReleased(MouseEvent e)
+ {
+ // FIXME: Not yet implemented.
+ }
+
+
+ /**
+ * Repeatedly invoked when the user is dragging the mouse cursor
+ * while having pressed a mouse button.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ // FIXME: Not yet implemented.
+ }
+
+
+ /**
+ * Repeatedly invoked when the user is dragging the mouse cursor
+ * without having pressed a mouse button.
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ // FIXME: Not yet implemented.
+ }
+ }
+
+
+ /**
+ * A small button for showing and hiding parts of a
+ * <code>JSplitPane</code> with a single mouse click.
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+ private static class OneTouchButton
+ extends JButton
+ {
+ OneTouchButton(boolean left)
+ {
+ // FIXME: Set various properties of the button.
+ // Make sure it looks identical to the small
+ // buttons of the Sun reference implementation.
+ // The size should also be the same.
+ if (left)
+ setText("<");
+ else
+ setText(">");
+
+ Dimension butSize = new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE);
+ setMinimumSize(butSize);
+ setMaximumSize(butSize);
+ setPreferredSize(butSize);
+
+ setBorderPainted(false);
+ }
+ }
+
+
+ /**
+ * Performs the tasks associated with an ongoing drag
+ * operation.
+ *
+ * @author Sascha Brawer (brawer@dandelis.ch)
+ */
+ protected class DragController
+ {
+ // FIXME: Not yet implemented.
+ protected DragController(MouseEvent e)
+ {
+ }
+
+ protected boolean isValid()
+ {
+ // FIXME: Not yet implemented.
+ return true;
+ }
+
+ protected int positionForMouseEvent(MouseEvent e)
+ {
+ return 0;
+ }
+
+ protected int getNeededLocation(int x, int y)
+ {
+ return 0;
+ }
+
+ protected void continueDrag(int newX, int newY)
+ {
+ }
+
+ protected void completeDrag(int x, int y)
+ {
+ }
+
+ protected void completeDrag(MouseEvent e)
+ {
+ }
+ }
+}
--- /dev/null
+/* BasicSplitPaneUI.java
+ Copyright (C) 2003 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.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusListener;
+import java.beans.PropertyChangeListener;
+import javax.swing.JComponent;
+import javax.swing.JSplitPane;
+import javax.swing.KeyStroke;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SplitPaneUI;
+
+/**
+ * FIXME: Stubbed to allow compiling other classes,
+ * no real implementation.
+ */
+public class BasicSplitPaneUI
+ extends SplitPaneUI
+{
+ protected static final String NON_CONTINUOUS_DIVIDER
+ = "nonContinuousDivider";
+
+ protected static int KEYBOARD_DIVIDER_MOVE_OFFSET;
+
+ protected JSplitPane splitPane;
+ protected BasicSplitPaneDivider divider;
+ protected PropertyChangeListener propertyChangeListener;
+ protected FocusListener focusListener;
+ protected int dividerSize;
+ protected Component nonContinuousLayoutDivider;
+ protected boolean draggingHW;
+ protected int beginDragDividerLocation;
+ protected KeyStroke upKey;
+ protected KeyStroke downKey;
+ protected KeyStroke leftKey;
+ protected KeyStroke rightKey;
+ protected KeyStroke homeKey;
+ protected KeyStroke endKey;
+ protected KeyStroke dividerResizeToggleKey;
+ protected ActionListener keyboardUpLeftListener;
+ protected ActionListener keyboardDownRightListener;
+ protected ActionListener keyboardHomeListener;
+ protected ActionListener keyboardEndListener;
+ protected ActionListener keyboardResizeToggleListener;
+
+ public static ComponentUI createUI(JComponent c)
+ {
+ BasicSplitPaneUI newUI;
+
+ newUI = new BasicSplitPaneUI();
+ newUI.installUI(c);
+ return newUI;
+ }
+
+ public BasicSplitPaneUI()
+ {
+ propertyChangeListener = createPropertyChangeListener();
+ focusListener = createFocusListener();
+ }
+
+ public void installUI(JComponent c)
+ {
+ }
+
+ protected void installDefaults()
+ {
+ }
+
+ protected void installListeners()
+ {
+ }
+
+ protected void installKeyboardListeners()
+ {
+ }
+
+ protected void installKeyboardActions()
+ {
+ }
+
+ public void uninstallUI(JComponent c)
+ {
+ }
+
+ protected void uninstallDefaults()
+ {
+ }
+
+ protected void uninstallListeners()
+ {
+ }
+
+ protected void uninstallKeyboardActions()
+ {
+ }
+
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return null;
+ }
+
+ protected FocusListener createFocusListener()
+ {
+ return null;
+ }
+
+ protected ActionListener createKeyboardUpLeftListener()
+ {
+ return null;
+ }
+
+ protected ActionListener createKeyboardDownRightListener()
+ {
+ return null;
+ }
+
+ protected ActionListener createKeyboardHomeListener()
+ {
+ return null;
+ }
+
+ protected ActionListener createKeyboardEndListener()
+ {
+ return null;
+ }
+
+ protected ActionListener createKeyboardResizeToggleListener()
+ {
+ return null;
+ }
+
+ public int getOrientation()
+ {
+ return splitPane.getOrientation();
+ }
+
+ public void setOrientation(int orientation)
+ {
+ }
+
+
+ public boolean isContinuousLayout()
+ {
+ return false;
+ }
+
+ public void setContinuousLayout(boolean b)
+ {
+ }
+
+ public int getLastDragLocation()
+ {
+ return 0;
+ }
+
+ public void setLastDragLocation(int l)
+ {
+ }
+
+
+ public BasicSplitPaneDivider getDivider()
+ {
+ return divider;
+ }
+
+
+ protected Component createDefaultNonContinuousLayoutDivider()
+ {
+ return null;
+ }
+
+ protected void setNonContinuousLayoutDivider(Component newDivider)
+ {
+ setNonContinuousLayoutDivider(newDivider, true /* false? */);
+ }
+
+ protected void setNonContinuousLayoutDivider(Component newDivider,
+ boolean rememberSizes)
+ {
+ nonContinuousLayoutDivider = newDivider;
+ }
+
+ public Component getNonContinuousLayoutDivider()
+ {
+ return nonContinuousLayoutDivider;
+ }
+
+ public JSplitPane getSplitPane()
+ {
+ return splitPane;
+ }
+
+ public BasicSplitPaneDivider createDefaultDivider()
+ {
+ return null;
+ }
+
+ public void resetToPreferredSizes(JSplitPane jc)
+ {
+ }
+
+ public void setDividerLocation(JSplitPane jc, int location)
+ {
+ }
+
+ public int getDividerLocation(JSplitPane jc)
+ {
+ return 0;
+ }
+
+ public int getMinimumDividerLocation(JSplitPane jc)
+ {
+ return 0;
+ }
+
+ public int getMaximumDividerLocation(JSplitPane jc)
+ {
+ return 0;
+ }
+
+ public void finishedPaintingChildren(JSplitPane jc, Graphics g)
+ {
+ }
+
+ public void paint(Graphics g, JComponent jc)
+ {
+ }
+
+ public Dimension getPreferredSize(JComponent jc)
+ {
+ return null;
+ }
+
+ public Dimension getMinimumSize(JComponent jc)
+ {
+ return null;
+ }
+
+ public Dimension getMaximumSize(JComponent jc)
+ {
+ return null;
+ }
+
+ public Insets getInsets(JComponent jc)
+ {
+ return new Insets(0, 0, 0, 0);
+ }
+
+ protected void resetLayoutManager()
+ {
+ }
+
+ protected void startDragging()
+ {
+ }
+
+ protected void dragDividerTo(int location)
+ {
+ }
+
+ protected void finishDraggingTo(int location)
+ {
+ }
+
+ protected int getDividerBorderSize()
+ {
+ return 0;
+ }
+}