diff options
Diffstat (limited to 'libjava/javax')
206 files changed, 7261 insertions, 4364 deletions
diff --git a/libjava/javax/swing/AbstractAction.java b/libjava/javax/swing/AbstractAction.java index d7518998273..4f0af1c9dd4 100644 --- a/libjava/javax/swing/AbstractAction.java +++ b/libjava/javax/swing/AbstractAction.java @@ -44,6 +44,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.HashMap; + import javax.swing.event.SwingPropertyChangeSupport; /** diff --git a/libjava/javax/swing/AbstractButton.java b/libjava/javax/swing/AbstractButton.java index 11ab1983ec6..adb3af40823 100644 --- a/libjava/javax/swing/AbstractButton.java +++ b/libjava/javax/swing/AbstractButton.java @@ -45,8 +45,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.beans.PropertyChangeEvent; @@ -240,7 +238,7 @@ public abstract class AbstractButton extends JComponent PropertyChangeListener actionPropertyChangeListener; /** ChangeEvent that is fired to button's ChangeEventListeners */ - private ChangeEvent changeEvent = new ChangeEvent(this); + protected ChangeEvent changeEvent = new ChangeEvent(this); /** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */ public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted"; @@ -441,8 +439,7 @@ public abstract class AbstractButton extends JComponent { return null; // TODO } - } - + } /** * Creates a new AbstractButton object. @@ -691,11 +688,8 @@ public abstract class AbstractButton extends JComponent /** * Calls {@link ChangeEvent.stateChanged} on each {@link ChangeListener} * in the button's listener list. - * - * @param e The event signifying a change in one of the (non-bound) - * properties of the button's model. */ - public void fireStateChanged(ChangeEvent e) + public void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); @@ -785,8 +779,8 @@ public abstract class AbstractButton extends JComponent { if (index < -1 || (text != null && index >= text.length())) throw new IllegalArgumentException(); - else - mnemonicIndex = index; + + mnemonicIndex = index; } /** @@ -892,14 +886,14 @@ public abstract class AbstractButton extends JComponent */ public void setHorizontalAlignment(int a) { + if (horizontalAlignment == a) + return; + int old = horizontalAlignment; horizontalAlignment = a; - if (old != a) - { - firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a); - revalidate(); - repaint(); - } + firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a); + revalidate(); + repaint(); } /** @@ -929,14 +923,14 @@ public abstract class AbstractButton extends JComponent */ public void setHorizontalTextPosition(int t) { + if (horizontalTextPosition == t) + return; + int old = horizontalTextPosition; horizontalTextPosition = t; - if (old != t) - { - firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); - revalidate(); - repaint(); - } + firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); + revalidate(); + repaint(); } /** @@ -964,14 +958,14 @@ public abstract class AbstractButton extends JComponent */ public void setVerticalAlignment(int a) { + if (verticalAlignment == a) + return; + int old = verticalAlignment; verticalAlignment = a; - if (old != a) - { - firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a); - revalidate(); - repaint(); - } + firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a); + revalidate(); + repaint(); } /** @@ -1001,14 +995,14 @@ public abstract class AbstractButton extends JComponent */ public void setVerticalTextPosition(int t) { + if (verticalTextPosition == t) + return; + int old = verticalTextPosition; verticalTextPosition = t; - if (old != t) - { - firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); - revalidate(); - repaint(); - } + firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); + revalidate(); + repaint(); } /** @@ -1032,14 +1026,14 @@ public abstract class AbstractButton extends JComponent */ public void setBorderPainted(boolean b) { + if (borderPainted == b) + return; + boolean old = borderPainted; - borderPainted = b; - if (b != old) - { - firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b); - revalidate(); - repaint(); - } + borderPainted = b; + firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b); + revalidate(); + repaint(); } /** @@ -1078,10 +1072,7 @@ public abstract class AbstractButton extends JComponent action.removePropertyChangeListener(actionPropertyChangeListener); actionPropertyChangeListener = null; } - - - } - + } Action old = action; action = a; @@ -1112,14 +1103,14 @@ public abstract class AbstractButton extends JComponent */ public void setIcon(Icon i) { - if (default_icon != i) - { + if (default_icon == i) + return; + Icon old = default_icon; default_icon = i; firePropertyChange(ICON_CHANGED_PROPERTY, old, i); revalidate(); repaint(); - } } /** @@ -1138,6 +1129,8 @@ public abstract class AbstractButton extends JComponent * "text" property. * * @param label The new "label" property + * + * @deprecated use <code>setText(text)</code> */ public void setLabel(String label) { @@ -1149,6 +1142,8 @@ public abstract class AbstractButton extends JComponent * the "text" property. * * @return The current "label" property + * + * @deprecated use <code>getText()</code> */ public String getLabel() { @@ -1163,15 +1158,15 @@ public abstract class AbstractButton extends JComponent */ public void setText(String t) { + if (text == t) + return; + String old = text; text = t; - if (t != old) - { - firePropertyChange(TEXT_CHANGED_PROPERTY, old, t); + firePropertyChange(TEXT_CHANGED_PROPERTY, old, t); revalidate(); repaint(); } - } /** * Set the value of the {@link #iconTextGap} property. @@ -1180,14 +1175,14 @@ public abstract class AbstractButton extends JComponent */ public void setIconTextGap(int i) { + if (iconTextGap == i) + return; + int old = iconTextGap; iconTextGap = i; - if (old != i) - { - fireStateChanged(new ChangeEvent(this)); - revalidate(); - repaint(); - } + fireStateChanged(); + revalidate(); + repaint(); } /** @@ -1207,7 +1202,7 @@ public abstract class AbstractButton extends JComponent * * @return The current "margin" property */ - public Insets getMargin() + public Insets getMargin() { return margin; } @@ -1221,15 +1216,15 @@ public abstract class AbstractButton extends JComponent */ public void setMargin(Insets m) { + if (margin == m) + return; + Insets old = margin; margin = m; - if (m != old) - { - firePropertyChange(MARGIN_CHANGED_PROPERTY, old, m); - revalidate(); + firePropertyChange(MARGIN_CHANGED_PROPERTY, old, m); + revalidate(); repaint(); } - } /** * Return the button's "pressedIcon" property. The look and feel class @@ -1254,15 +1249,15 @@ public abstract class AbstractButton extends JComponent */ public void setPressedIcon(Icon pressedIcon) { + if (pressed_icon == pressedIcon) + return; + Icon old = pressed_icon; pressed_icon = pressedIcon; - if (pressed_icon != old) - { - firePropertyChange(PRESSED_ICON_CHANGED_PROPERTY, old, pressed_icon); + firePropertyChange(PRESSED_ICON_CHANGED_PROPERTY, old, pressed_icon); revalidate(); repaint(); } - } /** * Return the button's "disabledIcon" property. The look and feel class @@ -1323,15 +1318,14 @@ public abstract class AbstractButton extends JComponent */ public void setFocusPainted(boolean p) { + if (focusPainted == p) + return; + boolean old = focusPainted; focusPainted = p; - - if (old != focusPainted) - { - firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, p); - revalidate(); - repaint(); - } + firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, p); + revalidate(); + repaint(); } /** @@ -1554,7 +1548,7 @@ public abstract class AbstractButton extends JComponent { public void stateChanged(ChangeEvent e) { - AbstractButton.this.fireStateChanged(e); + AbstractButton.this.fireStateChanged(); AbstractButton.this.repaint(); } }; @@ -1612,13 +1606,13 @@ public abstract class AbstractButton extends JComponent getModel().setArmed(true); getModel().setPressed(true); try - { + { java.lang.Thread.sleep(pressTime); - } + } catch (java.lang.InterruptedException e) - { + { // probably harmless - } + } getModel().setPressed(false); getModel().setArmed(false); } @@ -1644,22 +1638,20 @@ public abstract class AbstractButton extends JComponent * <code>true</code>. This icon can be <code>null</code>, in which case * it is synthesized from the button's selected icon. * - * @param disabledSelectedIcon The new disabled selected icon + * @param icon The new disabled selected icon */ - public void setDisabledSelectedIcon(Icon disabledSelectedIcon) + public void setDisabledSelectedIcon(Icon icon) { + if (disabledSelectedIcon == icon) + return; + Icon old = disabledSelectedIcon; - disabledSelectedIcon = disabledSelectedIcon; - if (old != disabledSelectedIcon) - { - firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old, - disabledSelectedIcon); - revalidate(); - repaint(); - } + disabledSelectedIcon = icon; + firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old, icon); + revalidate(); + repaint(); } - /** * Return the button's rollover icon. The look and feel class should * paint this icon when the "rolloverEnabled" property of the button is @@ -1681,15 +1673,14 @@ public abstract class AbstractButton extends JComponent */ public void setRolloverIcon(Icon r) { + if (rolloverIcon == r) + return; + Icon old = rolloverIcon; rolloverIcon = r; - if (old != rolloverIcon) - { - firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, - rolloverIcon); - revalidate(); - repaint(); - } + firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, rolloverIcon); + revalidate(); + repaint(); } /** @@ -1715,18 +1706,16 @@ public abstract class AbstractButton extends JComponent */ public void setRolloverSelectedIcon(Icon r) { + if (rolloverSelectedIcon == r) + return; + Icon old = rolloverSelectedIcon; rolloverSelectedIcon = r; - if (old != rolloverSelectedIcon) - { - firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, - rolloverSelectedIcon); - revalidate(); - repaint(); - } + firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, r); + revalidate(); + repaint(); } - /** * Return the button's selected icon. The look and feel class should * paint this icon when the "selected" property of the button's model is @@ -1752,15 +1741,14 @@ public abstract class AbstractButton extends JComponent */ public void setSelectedIcon(Icon s) { + if (selectedIcon == s) + return; + Icon old = selectedIcon; selectedIcon = s; - if (old != selectedIcon) - { - firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old, - selectedIcon); - revalidate(); - repaint(); - } + firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old, s); + revalidate(); + repaint(); } /** @@ -1777,9 +1765,9 @@ public abstract class AbstractButton extends JComponent Object[] objs = new Object[1]; objs[0] = getText(); return objs; - } + } else - { + { return null; } } @@ -1800,9 +1788,9 @@ public abstract class AbstractButton extends JComponent */ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) - { + { return current_icon == img; - } + } /** * Returns the value of the button's "contentAreaFilled" property. This @@ -1814,9 +1802,9 @@ public abstract class AbstractButton extends JComponent * @return The current value of the "contentAreaFilled" property */ public boolean isContentAreaFilled() - { + { return contentAreaFilled; - } + } /** * Sets the value of the button's "contentAreaFilled" property. This @@ -1828,16 +1816,16 @@ public abstract class AbstractButton extends JComponent * @param b The new value of the "contentAreaFilled" property */ public void setContentAreaFilled(boolean b) - { + { + if (contentAreaFilled == b) + return; + boolean old = contentAreaFilled; contentAreaFilled = b; - if (b != old) - { - firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b); - revalidate(); - repaint(); - } - } + firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b); + revalidate(); + repaint(); + } /** * Paints the button's border, if the button's "borderPainted" property is @@ -1846,10 +1834,10 @@ public abstract class AbstractButton extends JComponent * @param g The graphics context used to paint the border */ protected void paintBorder(Graphics g) - { + { if (isBorderPainted()) super.paintBorder(g); - } + } /** * Returns a string, used only for debugging, which identifies or somehow @@ -1862,7 +1850,6 @@ public abstract class AbstractButton extends JComponent return "AbstractButton"; } - /** * Set the "UI" property of the button, which is a look and feel class * responsible for handling the button's input events and painting it. @@ -1870,9 +1857,9 @@ public abstract class AbstractButton extends JComponent * @param ui The new "UI" property */ public void setUI(ButtonUI ui) - { + { super.setUI(ui); - } + } /** * Set the "UI" property of the button, which is a look and feel class @@ -1883,7 +1870,7 @@ public abstract class AbstractButton extends JComponent public ButtonUI getUI() { return (ButtonUI) ui; - } + } /** * Set the "UI" property to a class constructed, via the {@link diff --git a/libjava/javax/swing/AbstractCellEditor.java b/libjava/javax/swing/AbstractCellEditor.java index 3463c97547c..196e2e2696c 100644 --- a/libjava/javax/swing/AbstractCellEditor.java +++ b/libjava/javax/swing/AbstractCellEditor.java @@ -40,6 +40,7 @@ package javax.swing; import java.io.Serializable; import java.util.EventObject; + import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.EventListenerList; diff --git a/libjava/javax/swing/AbstractListModel.java b/libjava/javax/swing/AbstractListModel.java index 4a5c14bed08..9fe1bcbee2f 100644 --- a/libjava/javax/swing/AbstractListModel.java +++ b/libjava/javax/swing/AbstractListModel.java @@ -1,5 +1,5 @@ /* AbstractListModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,15 +35,16 @@ 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; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.EventListenerList; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; - /** * AbstractListModel * diff --git a/libjava/javax/swing/AbstractSpinnerModel.java b/libjava/javax/swing/AbstractSpinnerModel.java index d2d345b8e14..1d3a621e429 100644 --- a/libjava/javax/swing/AbstractSpinnerModel.java +++ b/libjava/javax/swing/AbstractSpinnerModel.java @@ -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; import java.util.EventListener; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; diff --git a/libjava/javax/swing/ActionMap.java b/libjava/javax/swing/ActionMap.java index 98615914683..645252f5b26 100644 --- a/libjava/javax/swing/ActionMap.java +++ b/libjava/javax/swing/ActionMap.java @@ -44,7 +44,6 @@ import java.io.Serializable; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; diff --git a/libjava/javax/swing/BorderFactory.java b/libjava/javax/swing/BorderFactory.java index 1cc6cbf420d..4f0a1ee4e2e 100644 --- a/libjava/javax/swing/BorderFactory.java +++ b/libjava/javax/swing/BorderFactory.java @@ -1,5 +1,5 @@ -/* BorderFactory.java - Copyright (C) 2002 Free Software Foundation, Inc. +/* BorderFactory.java -- + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing; import java.awt.Color; import java.awt.Font; + import javax.swing.border.BevelBorder; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; @@ -51,6 +52,11 @@ import javax.swing.border.TitledBorder; public class BorderFactory { + private BorderFactory() + { + // Do nothing. + } + /** * Creates a line border withe the specified color. * diff --git a/libjava/javax/swing/Box.java b/libjava/javax/swing/Box.java index 26588a56457..7532d308712 100644 --- a/libjava/javax/swing/Box.java +++ b/libjava/javax/swing/Box.java @@ -38,13 +38,14 @@ exception statement from your version. */ package javax.swing; +import java.awt.AWTError; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.LayoutManager; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; -import java.awt.LayoutManager; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.AWTError; /** * A component that uses a {@link BoxLayout} as Layout Manager. diff --git a/libjava/javax/swing/ButtonModel.java b/libjava/javax/swing/ButtonModel.java index 2876c75dd00..0c704bed261 100644 --- a/libjava/javax/swing/ButtonModel.java +++ b/libjava/javax/swing/ButtonModel.java @@ -35,11 +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; import java.awt.ItemSelectable; import java.awt.event.ActionListener; import java.awt.event.ItemListener; + import javax.swing.event.ChangeListener; public interface ButtonModel extends ItemSelectable diff --git a/libjava/javax/swing/CellEditor.java b/libjava/javax/swing/CellEditor.java index 831cde0e7f9..5c298dbca1b 100644 --- a/libjava/javax/swing/CellEditor.java +++ b/libjava/javax/swing/CellEditor.java @@ -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; import java.util.EventObject; + import javax.swing.event.CellEditorListener; /** diff --git a/libjava/javax/swing/CellRendererPane.java b/libjava/javax/swing/CellRendererPane.java index 246916d01d9..6e6c2cad074 100644 --- a/libjava/javax/swing/CellRendererPane.java +++ b/libjava/javax/swing/CellRendererPane.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; import java.awt.Component; @@ -43,6 +44,7 @@ import java.awt.Graphics; import java.awt.Rectangle; import java.io.IOException; import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; diff --git a/libjava/javax/swing/DebugGraphics.java b/libjava/javax/swing/DebugGraphics.java index a3c3d39daa8..6aa80adf5af 100644 --- a/libjava/javax/swing/DebugGraphics.java +++ b/libjava/javax/swing/DebugGraphics.java @@ -48,678 +48,740 @@ import java.awt.image.ImageObserver; import java.io.PrintStream; import java.text.AttributedCharacterIterator; + /** * DebugGraphics * @author Andrew Selkirk * @version 1.0 */ -public class DebugGraphics extends Graphics { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * graphics - */ - Graphics graphics; - - /** - * buffer - */ - Image buffer; - - /** - * debugOptions - */ - int debugOptions; - - /** - * graphicsID - */ - int graphicsID; - - /** - * xOffset - */ - int xOffset; - - /** - * yOffset - */ - int yOffset; - - /** - * LOG_OPTION - */ - public static final int LOG_OPTION = 1; - - /** - * FLASH_OPTION - */ - public static final int FLASH_OPTION = 2; - - /** - * BUFFERED_OPTION - */ - public static final int BUFFERED_OPTION = 4; - - /** - * NONE_OPTION - */ - public static final int NONE_OPTION = -1; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DebugGraphics - */ - public DebugGraphics() { - // TODO - } // DebugGraphics() - - /** - * Constructor DebugGraphics - * @param graphics TODO - * @param component TODO - */ - public DebugGraphics(Graphics graphics, JComponent component) { - // TODO - } // DebugGraphics() - - /** - * Constructor DebugGraphics - * @param graphics TODO - */ - public DebugGraphics(Graphics graphics) { - // TODO - } // DebugGraphics() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * setColor - * @param value0 TODO - */ - public void setColor(Color color) { - // TODO - } // setColor() - - /** - * create - * @returns Graphics - */ - public Graphics create() { - return null; // TODO - } // create() - - /** - * create - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @returns Graphics - */ - public Graphics create(int valx, int y, int w, int h) { - return null; // TODO - } // create() - - /** - * flashColor - * @returns Color - */ - public static Color flashColor() { - return null; // TODO - } // flashColor() - - /** - * setFlashColor - * @param color TODO - */ - public static void setFlashColor(Color color) { - // TODO - } // setFlashColor() - - /** - * flashTime - * @returns int - */ - public static int flashTime() { - return 0; // TODO - } // flashTime() - - /** - * setFlashTime - * @param time TODO - */ - public static void setFlashTime(int time) { - // TODO - } // setFlashTime() - - /** - * flashCount - * @returns int - */ - public static int flashCount() { - return 0; // TODO - } // flashCount() - - /** - * setFlashCount - * @param count TODO - */ - public static void setFlashCount(int count) { - // TODO - } // setFlashCount() - - /** - * logStream - * @returns PrintStream - */ - public static PrintStream logStream() { - return null; // TODO - } // logStream() - - /** - * setLogStream - * @param stream TODO - */ - public static void setLogStream(PrintStream stream) { - // TODO - } // setLogStream() - - /** - * getFont - * @returns Font - */ - public Font getFont() { - return null; // TODO - } // getFont() - - /** - * setFont - * @param font TODO - */ - public void setFont(Font font) { - // TODO - } // setFont() - - /** - * getColor - * @returns Color - */ - public Color getColor() { - return null; // TODO - } // getColor() - - /** - * getFontMetrics - * @returns FontMetrics - */ - public FontMetrics getFontMetrics() { - return null; // TODO - } // getFontMetrics() - - /** - * getFontMetrics - * @param font TODO - * @returns FontMetrics - */ - public FontMetrics getFontMetrics(Font font) { - return null; // TODO - } // getFontMetrics() - - /** - * translate - * @param x TODO - * @param y TODO - */ - public void translate(int x, int y) { - // TODO - } // translate() - - /** - * setPaintMode - */ - public void setPaintMode() { - // TODO - } // setPaintMode() - - /** - * setXORMode - * @param color TODO - */ - public void setXORMode(Color color) { - // TODO - } // setXORMode() - - /** - * getClipBounds - * @returns Rectangle - */ - public Rectangle getClipBounds() { - return null; // TODO - } // getClipBounds() - - /** - * clipRect - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - */ - public void clipRect(int value0, int value1, int value2, int value3) { - // TODO - } // clipRect() - - /** - * setClip - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - */ - public void setClip(int x, int y, int w, int h) { - // TODO - } // setClip() - - /** - * getClip - * @returns Shape - */ - public Shape getClip() { - return null; // TODO - } // getClip() - - /** - * setClip - * @param shape TODO - */ - public void setClip(Shape shape) { - // TODO - } // setClip() - - /** - * drawRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param valh TODO - */ - public void drawRect(int x, int y, int w, int h) { - // TODO - } // drawRect() - - /** - * fillRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - */ - public void fillRect(int x, int y, int w, int h) { - // TODO - } // fillRect() - - /** - * clearRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - */ - public void clearRect(int x, int y, int w, int h) { - // TODO - } // clearRect() - - /** - * drawRoundRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param arcWidth TODO - * @param arcHeight TODO - */ - public void drawRoundRect(int x, int y, int w, int h, - int arcWidth, int arcHeight) { - // TODO - } // drawRoundRect() - - /** - * fillRoundRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param arcWidth TODO - * @param arcHeight TODO - */ - public void fillRoundRect(int x, int y, int w, int h, - int arcWidth, int arcHeight) { - // TODO - } // fillRoundRect() - - /** - * drawLine - * @param x1 TODO - * @param y1 TODO - * @param x2 TODO - * @param y2 TODO - */ - public void drawLine(int x1, int y1, int x2, int y2) { - // TODO - } // drawLine() - - /** - * draw3DRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param raised TODO - */ - public void draw3DRect(int x, int y, int w, int h, boolean raised) { - // TODO - } // draw3DRect() - - /** - * fill3DRect - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param raised TODO - */ - public void fill3DRect(int x, int y, int w, int h, boolean raised) { - // TODO - } // fill3DRect() - - /** - * drawOval - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - */ - public void drawOval(int x, int y, int w, int h) { - // TODO - } // drawOval() - - /** - * fillOval - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - */ - public void fillOval(int x, int y, int w, int h) { - // TODO - } // fillOval() - - /** - * drawArc - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param startAngle TODO - * @param arcAngle TODO - */ - public void drawArc(int x, int y, int w, int h, - int startAngle, int arcAngle) { - // TODO - } // drawArc() - - /** - * fillArc - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param startAngle TODO - * @param arcAngle TODO - */ - public void fillArc(int x, int y, int w, int h, - int startAngle, int arcAngle) { - // TODO - } // fillArc() - - /** - * drawPolyline - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void drawPolyline(int[] xpoints, int[] ypoints, int npoints) { - // TODO - } // drawPolyline() - - /** - * drawPolygon - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) { - // TODO - } // drawPolygon() - - /** - * fillPolygon - * @param xpoints TODO - * @param ypoints TODO - * @param npoints TODO - */ - public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) { - // TODO - } // fillPolygon() - - /** - * drawString - * @param string TODO - * @param x TODO - * @param y TODO - */ - public void drawString(String string, int s, int y) { - // TODO - } // drawString() - - /** - * drawString - * @param iterator TODO - * @param x TODO - * @param y TODO - */ - public void drawString(AttributedCharacterIterator iterator, - int x, int y) { - // TODO - } // drawString() - - /** - * drawBytes - * @param data TODO - * @param offset TODO - * @param length TODO - * @param x TODO - * @param y TODO - */ - public void drawBytes(byte[] data, int offset, int length, - int x, int y) { - // TODO - } // drawBytes() - - /** - * drawChars - * @param data TODO - * @param offset TODO - * @param length TODO - * @param value3 TODO - * @param value4 TODO - */ - public void drawChars(char[] data, int offset, int value2, - int x, int y) { - // TODO - } // drawChars() - - /** - * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int x, int y, - ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int x, int y, int w, - int h, ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param background TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int x, int y, - Color background, ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * drawImage - * @param image TODO - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param background TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int x, int y, int w, int h, - Color background, ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * drawImage - * @param image TODO - * @param dx1 TODO - * @param dy1 TODO - * @param dx2 TODO - * @param dy2 TODO - * @param sx1 TODO - * @param sy1 TODO - * @param sx2 TODO - * @param sy2 TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int dx1, int dy1, - int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * drawImage - * @param image TODO - * @param dx1 TODO - * @param dy1 TODO - * @param dx2 TODO - * @param dy2 TODO - * @param sx1 TODO - * @param sy1 TODO - * @param sx2 TODO - * @param sy2 TODO - * @param background TODO - * @param observer TODO - * @returns boolean - */ - public boolean drawImage(Image image, int dx1, int dy1, - int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - Color background, ImageObserver observer) { - return false; // TODO - } // drawImage() - - /** - * copyArea - * @param x TODO - * @param y TODO - * @param w TODO - * @param h TODO - * @param destx TODO - * @param desty TODO - */ - public void copyArea(int x, int y, int w, int h, - int destx, int desty) { - // TODO - } // copyArea() - - /** - * dispose - */ - public void dispose() { - // TODO - } // dispose() - - /** - * isDrawingBuffer - * @returns boolean - */ - public boolean isDrawingBuffer() { - return false; // TODO - } // isDrawingBuffer() - - /** - * toShortString - * @returns String - */ - String toShortString() { - return null; // TODO - } // toShortString() - - /** - * setDebugOptions - * @param options TODO - */ - public void setDebugOptions(int options) { - // TODO - } // setDebugOptions() - - /** - * getDebugOptions - * @returns int - */ - public int getDebugOptions() { - return 0; // TODO - } // getDebugOptions() - - -} // DebugGraphics +public class DebugGraphics extends Graphics +{ + + /** + * graphics + */ + Graphics graphics; + + /** + * buffer + */ + Image buffer; + + /** + * debugOptions + */ + int debugOptions; + + /** + * graphicsID + */ + int graphicsID; + + /** + * xOffset + */ + int xOffset; + + /** + * yOffset + */ + int yOffset; + + /** + * LOG_OPTION + */ + public static final int LOG_OPTION = 1; + + /** + * FLASH_OPTION + */ + public static final int FLASH_OPTION = 2; + + /** + * BUFFERED_OPTION + */ + public static final int BUFFERED_OPTION = 4; + + /** + * NONE_OPTION + */ + public static final int NONE_OPTION = -1; + + /** + * Creates a <code>DebugGraphics</code> object. + */ + public DebugGraphics() + { + // TODO + } + + /** + * Constructor DebugGraphics + * @param graphics TODO + * @param component TODO + */ + public DebugGraphics(Graphics graphics, JComponent component) + { + // TODO + } + + /** + * Constructor DebugGraphics + * @param graphics TODO + */ + public DebugGraphics(Graphics graphics) + { + // TODO + } + + /** + * setColor + * @param value0 TODO + */ + public void setColor(Color color) + { + // TODO + } + + /** + * create + * + * @return Graphics + */ + public Graphics create() + { + return null; // TODO + } + + /** + * create + * + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @returns Graphics + */ + public Graphics create(int valx, int y, int w, int h) + { + return null; // TODO + } + + /** + * flashColor + * + * @return Color + */ + public static Color flashColor() + { + return null; // TODO + } + + /** + * setFlashColor + * + * @param color the color to use for flashing + */ + public static void setFlashColor(Color color) + { + // TODO + } + + /** + * flashTime + * + * @return The time in milliseconds + */ + public static int flashTime() + { + return 0; // TODO + } + + /** + * setFlashTime + * + * @param time The time in milliseconds + */ + public static void setFlashTime(int time) + { + // TODO + } + + /** + * flashCount + * @returns int + */ + public static int flashCount() + { + return 0; // TODO + } + + /** + * setFlashCount + * + * @param count The number of flashes + */ + public static void setFlashCount(int count) + { + // TODO + } + + /** + * logStream + * + * @return The <code>PrintStream</code> to write logging messages to + */ + public static PrintStream logStream() + { + return null; // TODO + } + + /** + * setLogStream + * + * @param stream The currently set <code>PrintStream</code>. + */ + public static void setLogStream(PrintStream stream) + { + // TODO + } + + /** + * getFont + * @returns Font + */ + public Font getFont() + { + return null; // TODO + } + + /** + * setFont + * + * @param font The font to use for drawing text + */ + public void setFont(Font font) + { + // TODO + } + + /** + * getColor + * @returns Color + */ + public Color getColor() + { + return null; // TODO + } + + /** + * getFontMetrics + * @returns FontMetrics + */ + public FontMetrics getFontMetrics() + { + return null; // TODO + } + + /** + * getFontMetrics + * @param font TODO + * @returns FontMetrics + */ + public FontMetrics getFontMetrics(Font font) + { + return null; // TODO + } + + /** + * translate + * + * @param x TODO + * @param y TODO + */ + public void translate(int x, int y) + { + // TODO + } + + /** + * setPaintMode + */ + public void setPaintMode() + { + // TODO + } + + /** + * setXORMode + * + * @param color TODO + */ + public void setXORMode(Color color) + { + // TODO + } + + /** + * getClipBounds + * @returns Rectangle + */ + public Rectangle getClipBounds() + { + return null; // TODO + } + + /** + * clipRect + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + * @param value3 TODO + */ + public void clipRect(int value0, int value1, int value2, int value3) + { + // TODO + } + + /** + * setClip + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + */ + public void setClip(int x, int y, int w, int h) + { + // TODO + } + + /** + * getClip + * @returns Shape + */ + public Shape getClip() + { + return null; // TODO + } + + /** + * setClip + * @param shape TODO + */ + public void setClip(Shape shape) + { + // TODO + } + + /** + * drawRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param valh TODO + */ + public void drawRect(int x, int y, int w, int h) + { + // TODO + } // drawRect() + + /** + * fillRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + */ + public void fillRect(int x, int y, int w, int h) + { + // TODO + } // fillRect() + + /** + * clearRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + */ + public void clearRect(int x, int y, int w, int h) + { + // TODO + } + + /** + * drawRoundRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param arcWidth TODO + * @param arcHeight TODO + */ + public void drawRoundRect(int x, int y, int w, int h, int arcWidth, + int arcHeight) + { + // TODO + } + + /** + * fillRoundRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param arcWidth TODO + * @param arcHeight TODO + */ + public void fillRoundRect(int x, int y, int w, int h, int arcWidth, + int arcHeight) + { + // TODO + } + + /** + * drawLine + * @param x1 TODO + * @param y1 TODO + * @param x2 TODO + * @param y2 TODO + */ + public void drawLine(int x1, int y1, int x2, int y2) + { + // TODO + } + + /** + * draw3DRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param raised TODO + */ + public void draw3DRect(int x, int y, int w, int h, boolean raised) + { + // TODO + } + + /** + * fill3DRect + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param raised TODO + */ + public void fill3DRect(int x, int y, int w, int h, boolean raised) + { + // TODO + } + + /** + * drawOval + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + */ + public void drawOval(int x, int y, int w, int h) + { + // TODO + } + + /** + * fillOval + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + */ + public void fillOval(int x, int y, int w, int h) + { + // TODO + } + + /** + * drawArc + * + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param startAngle TODO + * @param arcAngle TODO + */ + public void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle) + { + // TODO + } + + /** + * fillArc + * + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param startAngle TODO + * @param arcAngle TODO + */ + public void fillArc(int x, int y, int w, int h, int startAngle, int arcAngle) + { + // TODO + } + + /** + * drawPolyline + * @param xpoints TODO + * @param ypoints TODO + * @param npoints TODO + */ + public void drawPolyline(int[] xpoints, int[] ypoints, int npoints) + { + // TODO + } + + /** + * drawPolygon + * + * @param xpoints TODO + * @param ypoints TODO + * @param npoints TODO + */ + public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) + { + // TODO + } + + /** + * fillPolygon + * + * @param xpoints TODO + * @param ypoints TODO + * @param npoints TODO + */ + public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) + { + // TODO + } + + /** + * drawString + * + * @param string TODO + * @param x TODO + * @param y TODO + */ + public void drawString(String string, int s, int y) + { + // TODO + } + + /** + * drawString + * + * @param iterator TODO + * @param x TODO + * @param y TODO + */ + public void drawString(AttributedCharacterIterator iterator, int x, int y) + { + // TODO + } + + /** + * drawBytes + * + * @param data TODO + * @param offset TODO + * @param length TODO + * @param x TODO + * @param y TODO + */ + public void drawBytes(byte[] data, int offset, int length, int x, int y) + { + // TODO + } + + /** + * drawChars + * @param data TODO + * @param offset TODO + * @param length TODO + * @param value3 TODO + * @param value4 TODO + */ + public void drawChars(char[] data, int offset, int value2, int x, int y) + { + // TODO + } // drawChars() + + /** + * drawImage + * @param image TODO + * @param x TODO + * @param y TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int x, int y, ImageObserver observer) + { + return false; // TODO + } + + /** + * drawImage + * @param image TODO + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int x, int y, int w, int h, + ImageObserver observer) + { + return false; // TODO + } + + /** + * drawImage + * @param image TODO + * @param x TODO + * @param y TODO + * @param background TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int x, int y, Color background, + ImageObserver observer) + { + return false; // TODO + } + + /** + * drawImage + * @param image TODO + * @param x TODO + * @param y TODO + * @param w TODO + * @param h TODO + * @param background TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int x, int y, int w, int h, + Color background, ImageObserver observer) + { + return false; // TODO + } + + /** + * drawImage + * + * @param image The image to draw + * @param dx1 TODO + * @param dy1 TODO + * @param dx2 TODO + * @param dy2 TODO + * @param sx1 TODO + * @param sy1 TODO + * @param sx2 TODO + * @param sy2 TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, + ImageObserver observer) + { + return false; // TODO + } + + /** + * drawImage + * + * @param image The image to draw + * @param dx1 TODO + * @param dy1 TODO + * @param dx2 TODO + * @param dy2 TODO + * @param sx1 TODO + * @param sy1 TODO + * @param sx2 TODO + * @param sy2 TODO + * @param background TODO + * @param observer TODO + * @returns boolean + */ + public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, + Color background, ImageObserver observer) + { + return false; // TODO + } + + /** + * copyArea + * + * @param x The x position of the source area + * @param y The y position of the source area + * @param width The width of the area + * @param height The height of the area + * @param destx The x position of the destination area + * @param desty The y posiiton of the destination area + */ + public void copyArea(int x, int y, int w, int h, int destx, int desty) + { + // TODO + } + + /** + * Releases all system resources that this <code>Graphics</code> is using. + */ + public void dispose() + { + // TODO + } + + /** + * isDrawingBuffer + * + * @return boolean + */ + public boolean isDrawingBuffer() + { + return false; // TODO + } + + /** + * toShortString + * @returns String + */ + String toShortString() + { + return null; // TODO + } // toShortString() + + /** + * setDebugOptions + * + * @param options the debug options + */ + public void setDebugOptions(int options) + { + // TODO + } + + /** + * getDebugOptions + * + * @return the debug options + */ + public int getDebugOptions() + { + return 0; // TODO + } +} diff --git a/libjava/javax/swing/DefaultBoundedRangeModel.java b/libjava/javax/swing/DefaultBoundedRangeModel.java index 3294c1d9e90..9a2d974cbaa 100644 --- a/libjava/javax/swing/DefaultBoundedRangeModel.java +++ b/libjava/javax/swing/DefaultBoundedRangeModel.java @@ -36,15 +36,16 @@ 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; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; - /** * A default implementation of BoundedRangeModel. * diff --git a/libjava/javax/swing/DefaultButtonModel.java b/libjava/javax/swing/DefaultButtonModel.java index 4c7c24772f9..543428a931d 100644 --- a/libjava/javax/swing/DefaultButtonModel.java +++ b/libjava/javax/swing/DefaultButtonModel.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; import java.awt.event.ActionEvent; @@ -44,11 +45,11 @@ import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; - /** * The purpose of this class is to model the dynamic state of an abstract * button. The concrete button type holding this state may be a a "toggle" diff --git a/libjava/javax/swing/DefaultCellEditor.java b/libjava/javax/swing/DefaultCellEditor.java index 39da1fb9f8e..1dd17b43555 100644 --- a/libjava/javax/swing/DefaultCellEditor.java +++ b/libjava/javax/swing/DefaultCellEditor.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; import java.awt.Component; @@ -44,6 +45,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.Serializable; import java.util.EventObject; + import javax.swing.table.TableCellEditor; import javax.swing.tree.TreeCellEditor; diff --git a/libjava/javax/swing/DefaultDesktopManager.java b/libjava/javax/swing/DefaultDesktopManager.java index 6678c931c6e..4928c5dc9f4 100644 --- a/libjava/javax/swing/DefaultDesktopManager.java +++ b/libjava/javax/swing/DefaultDesktopManager.java @@ -37,19 +37,15 @@ exception statement from your version. */ package javax.swing; -import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; -import java.awt.Graphics; import java.awt.Insets; import java.awt.Rectangle; import java.beans.PropertyVetoException; import java.io.Serializable; -import javax.swing.JDesktopPane; -import javax.swing.JInternalFrame; -import javax.swing.JInternalFrame.JDesktopIcon; +import javax.swing.JInternalFrame.JDesktopIcon; /** * DefaultDesktopManager is the default implementation of DesktopManager for diff --git a/libjava/javax/swing/DefaultListCellRenderer.java b/libjava/javax/swing/DefaultListCellRenderer.java index fe4b3d07048..4c4cee3c2bb 100644 --- a/libjava/javax/swing/DefaultListCellRenderer.java +++ b/libjava/javax/swing/DefaultListCellRenderer.java @@ -35,15 +35,16 @@ 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; import java.awt.Component; import java.awt.Rectangle; import java.io.Serializable; + import javax.swing.border.Border; import javax.swing.border.EmptyBorder; - /** * DefaultListCellRenderer. This class is responsible for rendering list * cells. diff --git a/libjava/javax/swing/DefaultListSelectionModel.java b/libjava/javax/swing/DefaultListSelectionModel.java index 4b8ddc355d3..d5801c7dde0 100644 --- a/libjava/javax/swing/DefaultListSelectionModel.java +++ b/libjava/javax/swing/DefaultListSelectionModel.java @@ -35,16 +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; import java.io.Serializable; -import java.util.EventListener; import java.util.BitSet; +import java.util.EventListener; + import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - /** * <p>This class provides a default implementation of {@link * ListSelectioModel}, which is used by {@link javax.swing.JList} and diff --git a/libjava/javax/swing/DefaultSingleSelectionModel.java b/libjava/javax/swing/DefaultSingleSelectionModel.java index e3f990d2f88..0b1371ed9e1 100644 --- a/libjava/javax/swing/DefaultSingleSelectionModel.java +++ b/libjava/javax/swing/DefaultSingleSelectionModel.java @@ -1,5 +1,5 @@ /* DefaultSingleSelectionModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -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; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; @@ -77,7 +79,7 @@ public class DefaultSingleSelectionModel /** * getSelectedIndex - * @returns int + * @return int */ public int getSelectedIndex () { @@ -111,7 +113,7 @@ public class DefaultSingleSelectionModel /** * isSelected - * @returns boolean + * @return boolean */ public boolean isSelected () { @@ -120,7 +122,8 @@ public class DefaultSingleSelectionModel /** * addChangeListener - * @param listener TODO + * + * @param listener the listener to add */ public void addChangeListener (ChangeListener listener) { @@ -129,7 +132,8 @@ public class DefaultSingleSelectionModel /** * removeChangeListener - * @param listener TODO + * + * @param listener the listener to remove */ public void removeChangeListener (ChangeListener listener) { @@ -159,8 +163,12 @@ public class DefaultSingleSelectionModel /** * getListeners - * @param listenerClass TODO - * @returns EventListener[] + * + * @param listenerClass the type fo listener + * + * @return an array of listeners + * + * @since 1.3 */ public EventListener[] getListeners (Class listenerClass) { @@ -169,6 +177,8 @@ public class DefaultSingleSelectionModel /** * getChangeListeners + * + * @since 1.4 */ public ChangeListener[] getChangeListeners () { diff --git a/libjava/javax/swing/FocusManager.java b/libjava/javax/swing/FocusManager.java index 6cbfa10f9d6..8e404e948ab 100644 --- a/libjava/javax/swing/FocusManager.java +++ b/libjava/javax/swing/FocusManager.java @@ -1,5 +1,5 @@ /* FocusManager.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -148,6 +148,7 @@ public abstract class FocusManager extends DefaultKeyboardFocusManager /** * disableSwingFocusManager + * @deprecated 1.4 */ public static void disableSwingFocusManager() { // TODO @@ -155,7 +156,8 @@ public abstract class FocusManager extends DefaultKeyboardFocusManager /** * isFocusManagerEnabled - * @returns boolean + * @return boolean + * @deprecated 1.4 */ public static boolean isFocusManagerEnabled() { return false; // TODO diff --git a/libjava/javax/swing/GrayFilter.java b/libjava/javax/swing/GrayFilter.java index 39ad4d35630..73302ad19dc 100644 --- a/libjava/javax/swing/GrayFilter.java +++ b/libjava/javax/swing/GrayFilter.java @@ -1,5 +1,5 @@ /* GrayFilter.java -- Java class for filtering Pixels to produce Gray Pictures - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,9 +39,9 @@ exception statement from your version. */ package javax.swing; import java.awt.Image; +import java.awt.Toolkit; import java.awt.image.FilteredImageSource; import java.awt.image.RGBImageFilter; -import java.awt.Toolkit; public class GrayFilter extends RGBImageFilter { diff --git a/libjava/javax/swing/InputMap.java b/libjava/javax/swing/InputMap.java index c737ae4db95..3f0bc3f47e6 100644 --- a/libjava/javax/swing/InputMap.java +++ b/libjava/javax/swing/InputMap.java @@ -44,7 +44,6 @@ import java.io.Serializable; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; diff --git a/libjava/javax/swing/InputVerifier.java b/libjava/javax/swing/InputVerifier.java index a125fe43502..ccd13d285cc 100644 --- a/libjava/javax/swing/InputVerifier.java +++ b/libjava/javax/swing/InputVerifier.java @@ -1,5 +1,5 @@ /* InputVerifier.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,43 +37,39 @@ exception statement from your version. */ package javax.swing; + /** * InputVerifier - * @author Andrew Selkirk - * @version 1.0 + * @author Andrew Selkirk + * @version 1.0 */ -public abstract class InputVerifier { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor InputVerifier - */ - public InputVerifier() { - } // InputVerifier() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * verify - * @param component TODO - * @returns boolean - */ - public abstract boolean verify(JComponent component); - - /** - * shouldYieldFocus - * @param component TODO - * @returns boolean - */ - public boolean shouldYieldFocus(JComponent component) { - return verify(component); - } // shouldYieldFocus() - - -} // InputVerifier +public abstract class InputVerifier +{ + /** + * Creates a <code>InputVerifier</code> + */ + public InputVerifier() + { + } + + /** + * verify + * + * @param component the component to verify + * + * @return <code>true</code> if valid, <code>false</code> otherwise. + */ + public abstract boolean verify(JComponent component); + + /** + * shouldYieldFocus + * + * @param component the component to verify + * + * @return <code>true</code> if valid, <code>false</code> otherwise. + */ + public boolean shouldYieldFocus(JComponent component) + { + return verify(component); + } +} diff --git a/libjava/javax/swing/JApplet.java b/libjava/javax/swing/JApplet.java index f1c3e354ff8..42d7426abcf 100644 --- a/libjava/javax/swing/JApplet.java +++ b/libjava/javax/swing/JApplet.java @@ -1,4 +1,4 @@ -/* JApplet.java -- +/* JApplet.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -47,169 +47,200 @@ import java.awt.Graphics; import java.awt.LayoutManager; import java.awt.event.KeyEvent; import java.awt.event.WindowEvent; + import javax.accessibility.AccessibleContext; -public class JApplet extends Applet implements RootPaneContainer +public class JApplet extends Applet + implements RootPaneContainer { private static final long serialVersionUID = 7269359214497372587L; + + public static final int HIDE_ON_CLOSE = 0; + public static final int EXIT_ON_CLOSE = 1; + public static final int DISPOSE_ON_CLOSE = 2; + public static final int DO_NOTHING_ON_CLOSE = 3; + + private int close_action = EXIT_ON_CLOSE; - public final static int HIDE_ON_CLOSE = 0; - public final static int EXIT_ON_CLOSE = 1; - public final static int DISPOSE_ON_CLOSE = 2; - public final static int DO_NOTHING_ON_CLOSE = 3; + protected JRootPane rootPane; + protected boolean rootPaneCheckingEnabled; - private int close_action = EXIT_ON_CLOSE; - private boolean checking; - protected JRootPane rootPane; + public JApplet() + { + frameInit(); + } - public JApplet() - { - frameInit(); - } - - public JApplet(String title) - { - frameInit(); - } + public JApplet(String title) + { + frameInit(); + } - protected void frameInit() - { - super.setLayout(new BorderLayout(1, 1)); - getRootPane(); // will do set/create - } + protected void frameInit() + { + super.setLayout(new BorderLayout(1, 1)); + getRootPane(); // will do set/create + } public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); - System.out.println("JFrame.getPrefSize(): " + d + " , comp="+ getComponentCount () + ", layout=" + getLayout()); + System.out.println("JFrame.getPrefSize(): " + d + " , comp=" + + getComponentCount() + ", layout=" + getLayout()); return d; } - public void setLayout(LayoutManager manager) - { super.setLayout(manager); } + public void setLayout(LayoutManager manager) + { + super.setLayout(manager); + } - public void setLayeredPane(JLayeredPane layeredPane) - { getRootPane().setLayeredPane(layeredPane); } - - public JLayeredPane getLayeredPane() - { return getRootPane().getLayeredPane(); } - - public JRootPane getRootPane() - { - if (rootPane == null) - setRootPane(createRootPane()); - return rootPane; - } - - public void setRootPane(JRootPane root) - { - if (rootPane != null) - remove(rootPane); - - rootPane = root; - add(rootPane, BorderLayout.CENTER); - } - - public JRootPane createRootPane() - { return new JRootPane(); } - - public Container getContentPane() - { return getRootPane().getContentPane(); } - - public void setContentPane(Container contentPane) - { getRootPane().setContentPane(contentPane); } - - public Component getGlassPane() - { return getRootPane().getGlassPane(); } - - public void setGlassPane(Component glassPane) - { getRootPane().setGlassPane(glassPane); } + public void setLayeredPane(JLayeredPane layeredPane) + { + getRootPane().setLayeredPane(layeredPane); + } + + public JLayeredPane getLayeredPane() + { + return getRootPane().getLayeredPane(); + } + public JRootPane getRootPane() + { + if (rootPane == null) + setRootPane(createRootPane()); + return rootPane; + } - ///////////////////////////////////////////////////////////////////////////////// - protected void addImpl(Component comp, Object constraints, int index) - { super.addImpl(comp, constraints, index); } - - public AccessibleContext getAccessibleContext() - { return null; } - - int getDefaultCloseOperation() - { return close_action; } - - - public JMenuBar getJMenuBar() - { return getRootPane().getJMenuBar(); } - - public void setJMenuBar(JMenuBar menubar) - { getRootPane().setJMenuBar(menubar); } - - - protected String paramString() - { return "JFrame"; } - - protected void processKeyEvent(KeyEvent e) - { super.processKeyEvent(e); } - - protected void processWindowEvent(WindowEvent e) - { - // System.out.println("PROCESS_WIN_EV-1: " + e); - - // super.processWindowEvent(e); - - // System.out.println("PROCESS_WIN_EV-2: " + e); - switch (e.getID()) - { - case WindowEvent.WINDOW_CLOSING: - { - switch(close_action) - { - case EXIT_ON_CLOSE: - { - System.out.println("user requested exit on close"); - System.exit(1); - break; - } - case DISPOSE_ON_CLOSE: - { - System.out.println("user requested dispose on close"); - //dispose(); - break; - } - case HIDE_ON_CLOSE: - - case DO_NOTHING_ON_CLOSE: - break; - } - break; - } - - case WindowEvent.WINDOW_CLOSED: - case WindowEvent.WINDOW_OPENED: - case WindowEvent.WINDOW_ICONIFIED: - case WindowEvent.WINDOW_DEICONIFIED: - case WindowEvent.WINDOW_ACTIVATED: - case WindowEvent.WINDOW_DEACTIVATED: - break; - } - } - - - public void remove(Component comp) - { getContentPane().remove(comp); } - + public void setRootPane(JRootPane root) + { + if (rootPane != null) + remove(rootPane); + + rootPane = root; + add(rootPane, BorderLayout.CENTER); + } + + public JRootPane createRootPane() + { + return new JRootPane(); + } + + public Container getContentPane() + { + return getRootPane().getContentPane(); + } + + public void setContentPane(Container contentPane) + { + getRootPane().setContentPane(contentPane); + } - void setDefaultCloseOperation(int operation) - { close_action = operation; } + public Component getGlassPane() + { + return getRootPane().getGlassPane(); + } + + public void setGlassPane(Component glassPane) + { + getRootPane().setGlassPane(glassPane); + } + + protected void addImpl(Component comp, Object constraints, int index) + { + super.addImpl(comp, constraints, index); + } + + public AccessibleContext getAccessibleContext() + { + return null; + } + + int getDefaultCloseOperation() + { + return close_action; + } + + public JMenuBar getJMenuBar() + { + return getRootPane().getJMenuBar(); + } + + public void setJMenuBar(JMenuBar menubar) + { + getRootPane().setJMenuBar(menubar); + } + protected String paramString() + { + return "JFrame"; + } + protected void processKeyEvent(KeyEvent e) + { + super.processKeyEvent(e); + } - protected boolean isRootPaneCheckingEnabled() - { return checking; } + protected void processWindowEvent(WindowEvent e) + { + // System.out.println("PROCESS_WIN_EV-1: " + e); + // super.processWindowEvent(e); + // System.out.println("PROCESS_WIN_EV-2: " + e); + switch (e.getID()) + { + case WindowEvent.WINDOW_CLOSING: + { + switch (close_action) + { + case EXIT_ON_CLOSE: + { + System.out.println("user requested exit on close"); + System.exit(1); + break; + } + case DISPOSE_ON_CLOSE: + { + System.out.println("user requested dispose on close"); + //dispose(); + break; + } + case HIDE_ON_CLOSE: + case DO_NOTHING_ON_CLOSE: + break; + } + break; + } + case WindowEvent.WINDOW_CLOSED: + case WindowEvent.WINDOW_OPENED: + case WindowEvent.WINDOW_ICONIFIED: + case WindowEvent.WINDOW_DEICONIFIED: + case WindowEvent.WINDOW_ACTIVATED: + case WindowEvent.WINDOW_DEACTIVATED: + break; + } + } + public void remove(Component comp) + { + getContentPane().remove(comp); + } - protected void setRootPaneCheckingEnabled(boolean enabled) - { checking = enabled; } + void setDefaultCloseOperation(int operation) + { + close_action = operation; + } - public void update(Graphics g) - { paint(g); } + protected boolean isRootPaneCheckingEnabled() + { + return rootPaneCheckingEnabled; + } + + protected void setRootPaneCheckingEnabled(boolean enabled) + { + rootPaneCheckingEnabled = enabled; + } + + public void update(Graphics g) + { + paint(g); + } } diff --git a/libjava/javax/swing/JCheckBox.java b/libjava/javax/swing/JCheckBox.java index 8490c0b91c0..36cd0715c70 100644 --- a/libjava/javax/swing/JCheckBox.java +++ b/libjava/javax/swing/JCheckBox.java @@ -48,6 +48,9 @@ import javax.accessibility.AccessibleContext; public class JCheckBox extends JToggleButton { private static final long serialVersionUID = -5246739313864538930L; + + public static final String BORDER_PAINTED_FLAT_CHANGED_PROPERTY = + "borderPaintedFlat"; private boolean borderPaintedFlat; diff --git a/libjava/javax/swing/JCheckBoxMenuItem.java b/libjava/javax/swing/JCheckBoxMenuItem.java index e0ebb7f8dfc..76377b618fc 100644 --- a/libjava/javax/swing/JCheckBoxMenuItem.java +++ b/libjava/javax/swing/JCheckBoxMenuItem.java @@ -35,15 +35,16 @@ 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; import java.io.IOException; import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; - /** * This class represents JCheckBoxMenuItem. Its behaviour is very similar * to JCheckBoxButton. Just like the JCheckBoxButton, user can check and diff --git a/libjava/javax/swing/JColorChooser.java b/libjava/javax/swing/JColorChooser.java index 6ba70ce99ba..27809cee09e 100644 --- a/libjava/javax/swing/JColorChooser.java +++ b/libjava/javax/swing/JColorChooser.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; import java.awt.AWTError; @@ -46,13 +47,11 @@ import java.awt.FlowLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.colorchooser.AbstractColorChooserPanel; -import javax.swing.colorchooser.ColorChooserComponentFactory; import javax.swing.colorchooser.ColorSelectionModel; import javax.swing.colorchooser.DefaultColorSelectionModel; import javax.swing.plaf.ColorChooserUI; diff --git a/libjava/javax/swing/JComboBox.java b/libjava/javax/swing/JComboBox.java index 9d480dc7c27..86f20b099eb 100644 --- a/libjava/javax/swing/JComboBox.java +++ b/libjava/javax/swing/JComboBox.java @@ -35,10 +35,9 @@ 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; -import java.awt.Component; -import java.awt.Dimension; import java.awt.ItemSelectable; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -50,12 +49,12 @@ import java.beans.PropertyChangeListener; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleAction; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleSelection; -import javax.swing.JComponent; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.PopupMenuListener; diff --git a/libjava/javax/swing/JComponent.java b/libjava/javax/swing/JComponent.java index eadf855a3ed..c22c2b2e702 100644 --- a/libjava/javax/swing/JComponent.java +++ b/libjava/javax/swing/JComponent.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; import java.awt.AWTEvent; @@ -68,7 +69,7 @@ import java.io.Serializable; import java.util.EventListener; import java.util.Hashtable; import java.util.Locale; -import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -79,7 +80,6 @@ import javax.swing.event.EventListenerList; import javax.swing.event.SwingPropertyChangeSupport; import javax.swing.plaf.ComponentUI; - /** * Every component in swing inherits from this class (JLabel, JButton, etc). * It contains generic methods to manage events, properties and sizes. Actual @@ -323,6 +323,9 @@ public abstract class JComponent extends Container implements Serializable private InputMap inputMap_whenAncestorOfFocused; private InputMap inputMap_whenInFocusedWindow; private ActionMap actionMap; + private InputVerifier inputVerifier; + + private TransferHandler transferHandler; /** * A lock held during recursive painting; this is used to serialize @@ -379,6 +382,9 @@ public abstract class JComponent extends Container implements Serializable public static final int WHEN_IN_FOCUSED_WINDOW = 2; + /** + * Creates a new <code>JComponent</code> instance. + */ public JComponent() { super(); @@ -611,8 +617,8 @@ public abstract class JComponent extends Container implements Serializable boolean newValue) { if (changeSupport != null) - changeSupport.firePropertyChange(propertyName, new Boolean(oldValue), - new Boolean(newValue)); + changeSupport.firePropertyChange(propertyName, Boolean.valueOf(oldValue), + Boolean.valueOf(newValue)); } /** @@ -796,13 +802,15 @@ public abstract class JComponent extends Container implements Serializable * Set the value of the {@link #border} property, revalidate * and repaint this component. * - * @param border The new value of the property + * @param newBorder The new value of the property * * @see #getBorder */ - public void setBorder(Border border) + public void setBorder(Border newBorder) { - this.border = border; + Border oldBorder = border; + border = newBorder; + firePropertyChange("border", oldBorder, newBorder); revalidate(); repaint(); } @@ -856,9 +864,10 @@ public abstract class JComponent extends Container implements Serializable */ protected Graphics getComponentGraphics(Graphics g) { - g.setFont(this.getFont()); - g.setColor(this.getForeground()); - return g; + Graphics g2 = g.create(); + g2.setFont(this.getFont()); + g2.setColor(this.getForeground()); + return g2; } @@ -1017,12 +1026,51 @@ public abstract class JComponent extends Container implements Serializable } /** - * Return the value of the {@link #nextFocusableComponent} property. + * Checks if a maximum size was explicitely set on the component. + * + * @return <code>true</code> if a maximum size was set, + * <code>false</code> otherwise * - * @deprecated See {@link java.awt.FocusTraversalPolicy} + * @since 1.3 + */ + public boolean isMaximumSizeSet() + { + return maximumSize != null; + } + + /** + * Checks if a minimum size was explicitely set on the component. + * + * @return <code>true</code> if a minimum size was set, + * <code>false</code> otherwise + * + * @since 1.3 + */ + public boolean isMinimumSizeSet() + { + return minimumSize != null; + } + + /** + * Checks if a preferred size was explicitely set on the component. + * + * @return <code>true</code> if a preferred size was set, + * <code>false</code> otherwise + * + * @since 1.3 + */ + public boolean isPreferredSizeSet() + { + return preferredSize != null; + } + + /** + * Return the value of the {@link #nextFocusableComponent} property. * * @return The current value of the property, or <code>null</code> * if none has been set. + * + * @deprecated See {@link java.awt.FocusTraversalPolicy} */ public Component getNextFocusableComponent() { @@ -1257,7 +1305,7 @@ public abstract class JComponent extends Container implements Serializable * @return <code>true</code> if you want this component to manage its own * focus, otherwise (by default) <code>false</code> * - * @deprecated Use {@link Component.setFocusTraversalKeys(int,Set)} and + * @deprecated 1.4 Use {@link Component.setFocusTraversalKeys(int,Set)} and * {@link Container.setFocusCycleRoot(boolean)} instead */ public boolean isManagingFocus() @@ -1641,9 +1689,6 @@ public abstract class JComponent extends Container implements Serializable } /** - * @deprecated As of 1.3 KeyStrokes can be registered with multiple - * simultaneous conditions. - * * Return the condition that determines whether a registered action * occurs in response to the specified keystroke. * @@ -1653,6 +1698,9 @@ public abstract class JComponent extends Container implements Serializable * #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link * #WHEN_IN_FOCUSED_WINDOW} * + * @deprecated As of 1.3 KeyStrokes can be registered with multiple + * simultaneous conditions. + * * @see #registerKeyboardAction * @see #unregisterKeyboardAction * @see #resetKeyboardActiond @@ -1673,14 +1721,14 @@ public abstract class JComponent extends Container implements Serializable } /** - * @deprecated Use {@link #getActionMap()} - * * Get the ActionListener (typically an {@link Action} object) which is * associated with a particular keystroke. * * @param aKeyStroke The keystroke to retrieve the action of * * @return The action associated with the specified keystroke + * + * @deprecated Use {@link #getActionMap()} */ public ActionListener getActionForKeyStroke(KeyStroke ks) { @@ -1907,11 +1955,13 @@ public abstract class JComponent extends Container implements Serializable * Set the value of the {@link #enabled} property, revalidate * and repaint this component. * - * @param e The new value of the property + * @param enable The new value of the property */ - public void setEnabled(boolean e) + public void setEnabled(boolean enable) { - super.setEnabled(e); + boolean oldEnabled = isEnabled(); + super.setEnabled(enable); + firePropertyChange("enabeld", oldEnabled, enable); revalidate(); repaint(); } @@ -1963,7 +2013,9 @@ public abstract class JComponent extends Container implements Serializable */ public void setMaximumSize(Dimension max) { + Dimension oldMaximumSize = maximumSize; maximumSize = max; + firePropertyChange("maximumSize", oldMaximumSize, maximumSize); revalidate(); repaint(); } @@ -1976,7 +2028,9 @@ public abstract class JComponent extends Container implements Serializable */ public void setMinimumSize(Dimension min) { + Dimension oldMinimumSize = minimumSize; minimumSize = min; + firePropertyChange("minimumSize", oldMinimumSize, minimumSize); revalidate(); repaint(); } @@ -1989,7 +2043,9 @@ public abstract class JComponent extends Container implements Serializable */ public void setPreferredSize(Dimension pref) { + Dimension oldPreferredSize = preferredSize; preferredSize = pref; + firePropertyChange("preferredSize", oldPreferredSize, preferredSize); } /** @@ -2016,6 +2072,32 @@ public abstract class JComponent extends Container implements Serializable } /** + * Get the value of the {@link #transferHandler} property. + * + * @return The current value of the property + * + * @see ComponentUI#setTransferHandler + */ + + public TransferHandler getTransferHandler() + { + return transferHandler; + } + + /** + * Set the value of the {@link #transferHandler} property. + * + * @param newHandler The new value of the property + * + * @see ComponentUI#getTransferHandler + */ + + void setTransferHandler (TransferHandler newHandler) + { + transferHandler = newHandler; + } + + /** * Set the value of the {@link #opaque} property, revalidate and repaint * this component. * @@ -2025,7 +2107,9 @@ public abstract class JComponent extends Container implements Serializable */ public void setOpaque(boolean isOpaque) { + boolean oldOpaque = opaque; opaque = isOpaque; + firePropertyChange("opaque", oldOpaque, opaque); revalidate(); repaint(); } @@ -2119,4 +2203,26 @@ public abstract class JComponent extends Container implements Serializable { defaultLocale = l; } + + /** + * Returns the currently set input verifier for this component. + * + * @return the input verifier, or <code>null</code> if none + */ + public InputVerifier getInputVerifier() + { + return inputVerifier; + } + + /** + * Sets the input verifier to use by this component. + * + * @param verifier the input verifier, or <code>null</code> + */ + public void setInputVerifier(InputVerifier verifier) + { + InputVerifier oldVerifier = inputVerifier; + inputVerifier = verifier; + firePropertyChange("inputVerifier", oldVerifier, verifier); + } } diff --git a/libjava/javax/swing/JDesktopPane.java b/libjava/javax/swing/JDesktopPane.java index ce8085a99f0..996aaf191bd 100644 --- a/libjava/javax/swing/JDesktopPane.java +++ b/libjava/javax/swing/JDesktopPane.java @@ -35,18 +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; import java.awt.Component; import java.beans.PropertyVetoException; -import java.io.IOException; -import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.plaf.DesktopPaneUI; - /** * JDesktopPane is a container (usually for JInternalFrames) that simulates a * desktop. Typically, the user will create JInternalFrames and place thme in @@ -63,14 +62,18 @@ public class JDesktopPane extends JLayeredPane implements Accessible /** * This specifies that when dragged, a JInternalFrame should be completely * visible. + * + * @specnote final since 1.5.0. */ - public static int LIVE_DRAG_MODE = 0; + public static final int LIVE_DRAG_MODE = 0; /** * This specifies that when dragged, a JInternalFrame should only be visible * as an outline. + * + * @specnote final since 1.5.0. */ - public static int OUTLINE_DRAG_MODE = 1; + public static final int OUTLINE_DRAG_MODE = 1; /** The selected frame in the JDesktopPane. */ private transient JInternalFrame selectedFrame; @@ -151,7 +154,10 @@ public class JDesktopPane extends JLayeredPane implements Accessible // FIXME: Unsupported mode. if (mode == OUTLINE_DRAG_MODE) - throw new IllegalArgumentException("Outline drag modes are unsupported."); + { + // throw new IllegalArgumentException("Outline drag modes are unsupported."); + mode = LIVE_DRAG_MODE; + } dragMode = mode; } diff --git a/libjava/javax/swing/JDialog.java b/libjava/javax/swing/JDialog.java index d3315801828..ace284bd5da 100644 --- a/libjava/javax/swing/JDialog.java +++ b/libjava/javax/swing/JDialog.java @@ -35,9 +35,9 @@ 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; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; @@ -45,14 +45,13 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.GraphicsConfiguration; +import java.awt.IllegalComponentStateException; import java.awt.LayoutManager; -import java.awt.event.KeyEvent; import java.awt.event.WindowEvent; -import java.awt.IllegalComponentStateException; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; - /** * Unlike JComponent derivatives, JDialog inherits from java.awt.Dialog. But * also lets a look-and-feel component to its work. @@ -77,7 +76,7 @@ public class JDialog extends Dialog implements Accessible, WindowConstants, private int close_action = HIDE_ON_CLOSE; /** Whether JDialogs are decorated by the Look and Feel. */ - private static boolean decorated = false; + private static boolean decorated; /** * Creates a new non-modal JDialog with no title diff --git a/libjava/javax/swing/JEditorPane.java b/libjava/javax/swing/JEditorPane.java index a36eba757ee..3b66c2bcb4e 100644 --- a/libjava/javax/swing/JEditorPane.java +++ b/libjava/javax/swing/JEditorPane.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; import java.awt.Dimension; import java.awt.event.KeyEvent; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import javax.accessibility.AccessibleContext; @@ -153,16 +154,9 @@ public class JEditorPane extends JTextComponent } protected InputStream getStream(URL page) + throws IOException { - try - { - return page.openStream(); - } - catch (Exception e) - { - System.out.println("Hhmmm, failed to open stream: " + e); - } - return null; + return page.openStream(); } public String getText() @@ -209,6 +203,7 @@ public class JEditorPane extends JTextComponent * This method initializes from a stream. */ public void read(InputStream in, Object desc) + throws IOException { } diff --git a/libjava/javax/swing/JFileChooser.java b/libjava/javax/swing/JFileChooser.java index 2a23eff2556..f653c708bd9 100644 --- a/libjava/javax/swing/JFileChooser.java +++ b/libjava/javax/swing/JFileChooser.java @@ -1,5 +1,5 @@ /* JFileChooser.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,6 +44,7 @@ import java.io.File; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; diff --git a/libjava/javax/swing/JFormattedTextField.java b/libjava/javax/swing/JFormattedTextField.java index 8074799a7ab..eaf53555ba1 100644 --- a/libjava/javax/swing/JFormattedTextField.java +++ b/libjava/javax/swing/JFormattedTextField.java @@ -42,6 +42,7 @@ import java.awt.event.FocusEvent; import java.io.Serializable; import java.text.Format; import java.text.ParseException; + import javax.swing.text.Document; import javax.swing.text.DocumentFilter; import javax.swing.text.NavigationFilter; diff --git a/libjava/javax/swing/JFrame.java b/libjava/javax/swing/JFrame.java index 3c254ab0448..aa641caa3c4 100644 --- a/libjava/javax/swing/JFrame.java +++ b/libjava/javax/swing/JFrame.java @@ -57,222 +57,223 @@ import javax.accessibility.AccessibleContext; * * @author Ronald Veldema (rveldema@cs.vu.nl) */ -public class JFrame extends Frame implements WindowConstants, RootPaneContainer +public class JFrame extends Frame + implements WindowConstants, RootPaneContainer { private static final long serialVersionUID = -3362141868504252139L; - - protected AccessibleContext accessibleContext; - - private int close_action = HIDE_ON_CLOSE; - - private static boolean defaultLookAndFeelDecorated = false; - - public static void setDefaultLookAndFeelDecorated(boolean d) + private static boolean defaultLookAndFeelDecorated; + private int close_action = HIDE_ON_CLOSE; + protected AccessibleContext accessibleContext; + protected JRootPane rootPane; + protected boolean rootPaneCheckingEnabled; + + public JFrame() { - defaultLookAndFeelDecorated = d; + super("JFrame"); + frameInit(); } - public static boolean isDefaultLookAndFeelDecorated() + public JFrame(String title) { - return defaultLookAndFeelDecorated; + super(title); + frameInit(); + } + + protected void frameInit() + { + super.setLayout(new BorderLayout(1, 1)); + enableEvents(AWTEvent.WINDOW_EVENT_MASK); + getRootPane(); // will do set/create } - /*************************************************** - * - * initia - * - * - *************/ - - - public JFrame() - { - super("JFrame"); - frameInit(); - } - - public JFrame(String title) - { - super(title); - frameInit(); - } - - - /*************************************************** - * - * - * methods, this part is shared with JDialog, JFrame - * - * - *************/ - - - private boolean checking; - protected JRootPane rootPane; - - - protected void frameInit() - { - super.setLayout(new BorderLayout(1, 1)); - enableEvents(AWTEvent.WINDOW_EVENT_MASK); - getRootPane(); // will do set/create - } - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - return d; + return super.getPreferredSize(); } public JMenuBar getJMenuBar() - { return getRootPane().getJMenuBar(); } - + { + return getRootPane().getJMenuBar(); + } + public void setJMenuBar(JMenuBar menubar) - { getRootPane().setJMenuBar(menubar); } - + { + getRootPane().setJMenuBar(menubar); + } + + public void setLayout(LayoutManager manager) + { + super.setLayout(manager); + } - public void setLayout(LayoutManager manager) - { super.setLayout(manager); } + public void setLayeredPane(JLayeredPane layeredPane) + { + getRootPane().setLayeredPane(layeredPane); + } - public void setLayeredPane(JLayeredPane layeredPane) - { getRootPane().setLayeredPane(layeredPane); } - public JLayeredPane getLayeredPane() - { return getRootPane().getLayeredPane(); } - + { + return getRootPane().getLayeredPane(); + } + public JRootPane getRootPane() - { - if (rootPane == null) - setRootPane(createRootPane()); - return rootPane; - } + { + if (rootPane == null) + setRootPane(createRootPane()); + return rootPane; + } public void setRootPane(JRootPane root) - { - if (rootPane != null) - remove(rootPane); - - rootPane = root; - add(rootPane, BorderLayout.CENTER); - } + { + if (rootPane != null) + remove(rootPane); + + rootPane = root; + add(rootPane, BorderLayout.CENTER); + } public JRootPane createRootPane() - { return new JRootPane(); } + { + return new JRootPane(); + } public Container getContentPane() - { return getRootPane().getContentPane(); } + { + return getRootPane().getContentPane(); + } public void setContentPane(Container contentPane) - { getRootPane().setContentPane(contentPane); } - + { + getRootPane().setContentPane(contentPane); + } + public Component getGlassPane() - { return getRootPane().getGlassPane(); } - + { + return getRootPane().getGlassPane(); + } + public void setGlassPane(Component glassPane) - { getRootPane().setGlassPane(glassPane); } + { + getRootPane().setGlassPane(glassPane); + } - - protected void addImpl(Component comp, Object constraints, int index) - { super.addImpl(comp, constraints, index); } + protected void addImpl(Component comp, Object constraints, int index) + { + super.addImpl(comp, constraints, index); + } + public void remove(Component comp) + { + getContentPane().remove(comp); + } - public void remove(Component comp) - { getContentPane().remove(comp); } - - protected boolean isRootPaneCheckingEnabled() - { return checking; } + protected boolean isRootPaneCheckingEnabled() + { + return rootPaneCheckingEnabled; + } + protected void setRootPaneCheckingEnabled(boolean enabled) + { + rootPaneCheckingEnabled = enabled; + } - protected void setRootPaneCheckingEnabled(boolean enabled) - { checking = enabled; } + public void update(Graphics g) + { + paint(g); + } + protected void processKeyEvent(KeyEvent e) + { + super.processKeyEvent(e); + } - public void update(Graphics g) - { paint(g); } + public static void setDefaultLookAndFeelDecorated(boolean decorated) + { + defaultLookAndFeelDecorated = decorated; + } - protected void processKeyEvent(KeyEvent e) - { super.processKeyEvent(e); } + public static boolean isDefaultLookAndFeelDecorated() + { + return defaultLookAndFeelDecorated; + } - ///////////////////////////////////////////////////////////////////////////////// - public AccessibleContext getAccessibleContext() { return accessibleContext; } - - public int getDefaultCloseOperation() - { return close_action; } - - - protected String paramString() - { return "JFrame"; } + public int getDefaultCloseOperation() + { + return close_action; + } + protected String paramString() + { + return "JFrame"; + } - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); - switch (e.getID()) + protected void processWindowEvent(WindowEvent e) + { + super.processWindowEvent(e); + switch (e.getID()) + { + case WindowEvent.WINDOW_CLOSING: + { + switch (close_action) { - case WindowEvent.WINDOW_CLOSING: - { - switch(close_action) - { - case EXIT_ON_CLOSE: - { - System.exit(0); - break; - } - case DISPOSE_ON_CLOSE: - { - dispose(); - break; - } - case HIDE_ON_CLOSE: - { - setVisible(false); - break; - } - case DO_NOTHING_ON_CLOSE: - break; - } - break; - } - - case WindowEvent.WINDOW_CLOSED: - case WindowEvent.WINDOW_OPENED: - case WindowEvent.WINDOW_ICONIFIED: - case WindowEvent.WINDOW_DEICONIFIED: - case WindowEvent.WINDOW_ACTIVATED: - case WindowEvent.WINDOW_DEACTIVATED: + case EXIT_ON_CLOSE: + { + System.exit(0); + break; + } + case DISPOSE_ON_CLOSE: + { + dispose(); break; + } + case HIDE_ON_CLOSE: + { + setVisible(false); + break; + } + case DO_NOTHING_ON_CLOSE: + break; } - } - - /** - * Defines what happens when this frame is closed. Can be one off - * <code>EXIT_ON_CLOSE</code>, - * <code>DISPOSE_ON_CLOSE</code>, - * <code>HIDE_ON_CLOSE</code> or - * <code>DO_NOTHING_ON_CLOSE</code>. - * The default is <code>HIDE_ON_CLOSE</code>. - * When <code>EXIT_ON_CLOSE</code> is specified this method calls - * <code>SecurityManager.checkExit(0)</code> which might throw a - * <code>SecurityException</code>. When the specified operation is - * not one of the above a <code>IllegalArgumentException</code> is - * thrown. - */ - public void setDefaultCloseOperation(int operation) - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null && operation == EXIT_ON_CLOSE) - sm.checkExit(0); - - if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE - && operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE) - throw new IllegalArgumentException("operation = " + operation); - - close_action = operation; - } + break; + } + case WindowEvent.WINDOW_CLOSED: + case WindowEvent.WINDOW_OPENED: + case WindowEvent.WINDOW_ICONIFIED: + case WindowEvent.WINDOW_DEICONIFIED: + case WindowEvent.WINDOW_ACTIVATED: + case WindowEvent.WINDOW_DEACTIVATED: + break; + } + } + /** + * Defines what happens when this frame is closed. Can be one off + * <code>EXIT_ON_CLOSE</code>, + * <code>DISPOSE_ON_CLOSE</code>, + * <code>HIDE_ON_CLOSE</code> or + * <code>DO_NOTHING_ON_CLOSE</code>. + * The default is <code>HIDE_ON_CLOSE</code>. + * When <code>EXIT_ON_CLOSE</code> is specified this method calls + * <code>SecurityManager.checkExit(0)</code> which might throw a + * <code>SecurityException</code>. When the specified operation is + * not one of the above a <code>IllegalArgumentException</code> is + * thrown. + */ + public void setDefaultCloseOperation(int operation) + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null && operation == EXIT_ON_CLOSE) + sm.checkExit(0); + + if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE + && operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE) + throw new IllegalArgumentException("operation = " + operation); + + close_action = operation; + } } diff --git a/libjava/javax/swing/JInternalFrame.java b/libjava/javax/swing/JInternalFrame.java index 12c9d139db2..ead61f218fa 100644 --- a/libjava/javax/swing/JInternalFrame.java +++ b/libjava/javax/swing/JInternalFrame.java @@ -35,9 +35,9 @@ 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; -import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Graphics; @@ -45,6 +45,7 @@ import java.awt.KeyboardFocusManager; import java.awt.LayoutManager; import java.awt.Rectangle; import java.beans.PropertyVetoException; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -54,7 +55,6 @@ import javax.swing.event.InternalFrameListener; import javax.swing.plaf.DesktopIconUI; import javax.swing.plaf.InternalFrameUI; - /** * This class implements a Swing widget that looks and acts like a native * frame. The frame can be dragged, resized, closed, etc. Typically, @@ -341,67 +341,67 @@ public class JInternalFrame extends JComponent implements Accessible, * The property fired in a PropertyChangeEvent when the contentPane property * changes. */ - public static String CONTENT_PANE_PROPERTY = "contentPane"; + public static final String CONTENT_PANE_PROPERTY = "contentPane"; /** * The property fired in a PropertyChangeEvent when the frameIcon property * changes. */ - public static String FRAME_ICON_PROPERTY = "frameIcon"; + public static final String FRAME_ICON_PROPERTY = "frameIcon"; /** * The property fired in a PropertyChangeEvent when the glassPane property * changes. */ - public static String GLASS_PANE_PROPERTY = "glassPane"; + public static final String GLASS_PANE_PROPERTY = "glassPane"; /** * The property fired in a PropertyChangeEvent when the closed property * changes. */ - public static String IS_CLOSED_PROPERTY = "closed"; + public static final String IS_CLOSED_PROPERTY = "closed"; /** * The property fired in a PropertyChangeEvent when the icon property * changes. */ - public static String IS_ICON_PROPERTY = "icon"; + public static final String IS_ICON_PROPERTY = "icon"; /** * The property fired in a PropertyChangeEvent when the maximum property * changes. */ - public static String IS_MAXIMUM_PROPERTY = "maximum"; + public static final String IS_MAXIMUM_PROPERTY = "maximum"; /** * The property fired in a PropertyChangeEvent when the selected property * changes. */ - public static String IS_SELECTED_PROPERTY = "selected"; + public static final String IS_SELECTED_PROPERTY = "selected"; /** * The property fired in a PropertyChangeEvent when the layeredPane property * changes. */ - public static String LAYERED_PANE_PROPERTY = "layeredPane"; + public static final String LAYERED_PANE_PROPERTY = "layeredPane"; /** * The property fired in a PropertyChangeEvent when the jMenuBar property * changes. */ - public static String MENU_BAR_PROPERTY = "jMenuBar"; + public static final String MENU_BAR_PROPERTY = "JMenuBar"; /** * The property fired in a PropertyChangeEvent when the rootPane property * changes. */ - public static String ROOT_PANE_PROPERTY = "rootPane"; + public static final String ROOT_PANE_PROPERTY = "rootPane"; /** * The property fired in a PropertyChangeEvent when the title property * changes. */ - public static String TITLE_PROPERTY = "title"; + public static final String TITLE_PROPERTY = "title"; /** Whether the JInternalFrame is closable. */ protected boolean closable; @@ -879,6 +879,8 @@ public class JInternalFrame extends JComponent implements Accessible, * JInternalFrame. * * @return The JMenuBar for this JInternalFrame. + * + * @deprecated 1.0.3 */ public JMenuBar getMenuBar() { @@ -1482,6 +1484,8 @@ public class JInternalFrame extends JComponent implements Accessible, * JInternalFrame. * * @param m The JMenuBar to use with this JInternalFrame. + * + * @deprecated 1.0.3 */ public void setMenuBar(JMenuBar m) { @@ -1702,6 +1706,6 @@ public class JInternalFrame extends JComponent implements Accessible, boolean newValue) throws PropertyVetoException { - super.fireVetoableChange(name, new Boolean(oldValue), new Boolean(newValue)); + super.fireVetoableChange(name, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); } -} // class JInternalFrame +} diff --git a/libjava/javax/swing/JLabel.java b/libjava/javax/swing/JLabel.java index 652c965e545..b3d7225b1e4 100644 --- a/libjava/javax/swing/JLabel.java +++ b/libjava/javax/swing/JLabel.java @@ -35,22 +35,20 @@ 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; import java.awt.Component; import java.awt.Font; import java.awt.Image; import java.awt.event.KeyEvent; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; -import javax.swing.Icon; import javax.swing.plaf.LabelUI; - /** - * <p> * A swing widget that displays a text message and/or an icon. - * </p> */ public class JLabel extends JComponent implements Accessible, SwingConstants { diff --git a/libjava/javax/swing/JLayeredPane.java b/libjava/javax/swing/JLayeredPane.java index a184e215a73..a200f289258 100644 --- a/libjava/javax/swing/JLayeredPane.java +++ b/libjava/javax/swing/JLayeredPane.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; import java.awt.Component; @@ -42,6 +43,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; + import javax.accessibility.Accessible; /** diff --git a/libjava/javax/swing/JList.java b/libjava/javax/swing/JList.java index b7638810c0b..d88a4db599c 100644 --- a/libjava/javax/swing/JList.java +++ b/libjava/javax/swing/JList.java @@ -1,5 +1,5 @@ /* JList.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,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; import java.awt.Color; @@ -44,6 +45,7 @@ import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.event.ListDataEvent; @@ -52,7 +54,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.plaf.ListUI; - /** * <p>This class is a facade over three separate objects: {@link * javax.swing.ListModel}, {@link javax.swing.ListSelectionModel} and diff --git a/libjava/javax/swing/JMenu.java b/libjava/javax/swing/JMenu.java index 60e94418d40..812c26bed01 100644 --- a/libjava/javax/swing/JMenu.java +++ b/libjava/javax/swing/JMenu.java @@ -35,11 +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; import java.awt.Component; import java.awt.Point; -import java.awt.Window; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -49,18 +49,15 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.EventListener; -import java.util.Hashtable; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleSelection; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; import javax.swing.plaf.MenuItemUI; - /** * <p> * This class represents a menu that can be added to a menu bar or @@ -140,7 +137,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public JMenu(String text, boolean tearoff) { - throw new Error("not implemented"); + // FIXME: tearoff not implemented + this(text); } private void writeObject(ObjectOutputStream stream) throws IOException @@ -644,16 +642,28 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement } /** + * Returns all registered <code>MenuListener</code> objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public MenuListener[] getMenuListeners() + { + return (MenuListener[]) listenerList.getListeners(MenuListener.class); + } + + /** * This method fires MenuEvents to all menu's MenuListeners. In this case * menuSelected() method of MenuListeners is called to indicated that the menu * was selected. */ protected void fireMenuSelected() { - EventListener[] ll = listenerList.getListeners(MenuListener.class); + MenuListener[] listeners = getMenuListeners(); - for (int i = 0; i < ll.length; i++) - ((MenuListener) ll[i]).menuSelected(menuEvent); + for (int index = 0; index < listeners.length; ++index) + listeners[index].menuSelected(menuEvent); } /** diff --git a/libjava/javax/swing/JMenuBar.java b/libjava/javax/swing/JMenuBar.java index f63b3630c3c..904ba3b69a3 100644 --- a/libjava/javax/swing/JMenuBar.java +++ b/libjava/javax/swing/JMenuBar.java @@ -35,35 +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; -import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.Point; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; -import javax.accessibility.AccessibleRole; -import javax.accessibility.AccessibleSelection; -import javax.accessibility.AccessibleStateSet; -import javax.accessibility.AccessibleValue; -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.plaf.MenuBarUI; -import javax.swing.plaf.MenuItemUI; - /** * <p> @@ -480,8 +463,7 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement */ public void updateUI() { - MenuBarUI ui = ((MenuBarUI) UIManager.getUI(this)); - setUI(ui); + setUI((MenuBarUI) UIManager.getUI(this)); invalidate(); } } diff --git a/libjava/javax/swing/JMenuItem.java b/libjava/javax/swing/JMenuItem.java index 6bf2abc0556..0aaf0c790e2 100644 --- a/libjava/javax/swing/JMenuItem.java +++ b/libjava/javax/swing/JMenuItem.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; import java.awt.Component; @@ -47,10 +48,10 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.EventListener; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; -import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.MenuDragMouseEvent; @@ -528,19 +529,20 @@ public class JMenuItem extends AbstractButton implements Accessible, */ public void menuSelectionChanged(boolean changed) { + Component parent = this.getParent(); if (changed) { model.setArmed(true); - if (this.getParent() instanceof JPopupMenu) - ((JPopupMenu) this.getParent()).setSelected(this); + if (parent != null && parent instanceof JPopupMenu) + ((JPopupMenu) parent).setSelected(this); } else { model.setArmed(false); - if (this.getParent() instanceof JPopupMenu) - ((JPopupMenu) this.getParent()).getSelectionModel().clearSelection(); + if (parent != null && parent instanceof JPopupMenu) + ((JPopupMenu) parent).getSelectionModel().clearSelection(); } } diff --git a/libjava/javax/swing/JOptionPane.java b/libjava/javax/swing/JOptionPane.java index 07042707220..26236822cec 100644 --- a/libjava/javax/swing/JOptionPane.java +++ b/libjava/javax/swing/JOptionPane.java @@ -35,22 +35,20 @@ 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; import java.awt.Component; -import java.awt.Dialog; import java.awt.Dimension; import java.awt.Frame; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; -import javax.swing.Icon; -import javax.swing.JInternalFrame; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; import javax.swing.plaf.OptionPaneUI; - /** * This class creates different types of JDialogs and JInternalFrames that can * ask users for input or pass on information. JOptionPane can be used by diff --git a/libjava/javax/swing/JPanel.java b/libjava/javax/swing/JPanel.java index 29abffc6cee..34a7c9fdcdd 100644 --- a/libjava/javax/swing/JPanel.java +++ b/libjava/javax/swing/JPanel.java @@ -35,15 +35,16 @@ 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; import java.awt.FlowLayout; import java.awt.LayoutManager; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.plaf.PanelUI; - /** * An instance of JPanel can be added to a panel, frame etc * diff --git a/libjava/javax/swing/JPasswordField.java b/libjava/javax/swing/JPasswordField.java index b8c88055fc4..133c99ac310 100644 --- a/libjava/javax/swing/JPasswordField.java +++ b/libjava/javax/swing/JPasswordField.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; import java.io.IOException; import java.io.ObjectOutputStream; + import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.text.BadLocationException; @@ -75,164 +77,186 @@ public class JPasswordField extends JTextField } } - /** - * uiClassID - */ - private static final String uiClassID = "PasswordFieldUI"; - - /** - * echoChar. Default is 0 - */ - private char echoChar = 0; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor JPasswordField - */ - public JPasswordField() { - // TODO - } // JPasswordField() - - /** - * Constructor JPasswordField - * @param text TODO - */ - public JPasswordField(String text) { - // TODO - } // JPasswordField() - - /** - * Constructor JPasswordField - * @param columns TODO - */ - public JPasswordField(int columns) { - // TODO - } // JPasswordField() - - /** - * Constructor JPasswordField - * @param text TODO - * @param columns TODO - */ - public JPasswordField(String text, int columns) { - // TODO - } // JPasswordField() - - /** - * Constructor JPasswordField - * @param document TODO - * @param text TODO - * @param columns TODO - */ - public JPasswordField(Document document, String text, int columns) { - // TODO - } // JPasswordField() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param stream TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream stream) throws IOException { - // TODO - } // writeObject() - - /** - * copy - */ - public void copy() { - // TODO - } // copy() - - /** - * getUIClassID - * @returns String - */ - public String getUIClassID() { - return uiClassID; - } // getUIClassID() - - /** - * getEchoChar - * @returns char - */ - public char getEchoChar() { - return echoChar; - } // getEchoChar() - - /** - * setEchoChar - * @param echo TODO - */ - public void setEchoChar(char echo) { - this.echoChar = echo; - // TODO - } // setEchoChar() - - /** - * echoCharIsSet - * @returns boolean - */ - public boolean echoCharIsSet() { - return (echoChar == 0); - } // echoCharIsSet() - - /** - * cut - */ - public void cut() { - // TODO - } // cut() - - /** - * getText - * @returns String - * @deprecated - */ - public String getText() { - return null; // TODO - } // getText() - - /** - * getText - * @param offset TODO - * @param length TODO - * @exception BadLocationException TODO - * @returns String - * @deprecated - */ - public String getText(int offset, int length) throws BadLocationException { - return null; // TODO - } // getText() - - /** - * getPassword - * @returns char[] - */ - public char[] getPassword() { - return null; // TODO - } // getPassword() - - /** - * paramString - * @returns String - */ - protected String paramString() { - return null; // TODO - } // paramString() + /** + * echoChar. Default is 0. + */ + private char echoChar = 0; + + /** + * Constructor JPasswordField + */ + public JPasswordField() + { + this(null, null, 0); + } + + /** + * Creates a <code>JPasswordField</code> object. + * + * @param text the initial text + */ + public JPasswordField(String text) + { + this(null, text, 0); + } + + /** + * Creates a <code>JPasswordField</code> object. + * + * @param columns the number of columns + */ + public JPasswordField(int columns) + { + this(null, null, columns); + } + + /** + * Creates a <code>JPasswordField</code> object. + * + * @param text the initial text + * @param columns the number of columns + */ + public JPasswordField(String text, int columns) + { + this(null, text, columns); + } + + /** + * Creates a <code>JPasswordField</code> object. + * + * @param document the document to use + * @param text the initial text + * @param columns the number of columns + */ + public JPasswordField(Document document, String text, int columns) + { + super(document, text, columns); + } + + /** + * writeObject + * + * @param stream the stream to write to + * + * @exception IOException if an error occurs + */ + private void writeObject(ObjectOutputStream stream) throws IOException + { + // TODO: Implement me. + } + + /** + * Returns the <code>UIClassID</code> + * + * @return the string "PasswordFieldUI" + */ + public String getUIClassID() + { + return "PasswordFieldUI"; + } + + /** + * getEchoChar + * + * @return the echo char + */ + public char getEchoChar() + { + return echoChar; + } + + /** + * setEchoChar + * + * @param echo the echo char + */ + public void setEchoChar(char echo) + { + this.echoChar = echo; + } + + /** + * echoCharIsSet + * + * @return <code>true</code> if the echo char is set, + * <code>false</code> otherwise. + */ + public boolean echoCharIsSet() + { + return echoChar == 0; + } + + /** + * Copies the selected text into the clipboard. This operation is not + * allowed in a password input field. + */ + public void copy() + { + UIManager.getLookAndFeel().provideErrorFeedback(this); + } + + /** + * Cuts the selected text and puts it into the clipboard. This operation + * is not allowed in a password input field. + */ + public void cut() + { + UIManager.getLookAndFeel().provideErrorFeedback(this); + } + + /** + * getText + * + * @return String + * + * @deprecated + */ + public String getText() + { + return null; // TODO + } + + /** + * getText + * + * @param offset TODO + * @param length TODO + * + * @return String + * + * @exception BadLocationException TODO + * + * @deprecated + */ + public String getText(int offset, int length) throws BadLocationException + { + return null; // TODO + } + + /** + * getPassword + * + * @return char[] + */ + public char[] getPassword() + { + return null; // TODO + } + + /** + * paramString + * + * @return String + */ + protected String paramString() + { + return null; // TODO + } /** * getAccessibleContext - * @return AccessibleContext + * + * @return the <code>AccessibleContext</code> object */ public AccessibleContext getAccessibleContext() { diff --git a/libjava/javax/swing/JPopupMenu.java b/libjava/javax/swing/JPopupMenu.java index d7d3e43f86f..76f63621d7e 100644 --- a/libjava/javax/swing/JPopupMenu.java +++ b/libjava/javax/swing/JPopupMenu.java @@ -35,21 +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; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; -import java.awt.Frame; import java.awt.Graphics; import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.LayoutManager; import java.awt.Panel; import java.awt.Point; -import java.awt.Window; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; @@ -58,7 +54,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.EventListener; -import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -66,7 +62,6 @@ import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import javax.swing.plaf.PopupMenuUI; - /** * JPopupMenu is a container that is used to display popup menu's menu * items. By default JPopupMenu is a lightweight container, however if it diff --git a/libjava/javax/swing/JRadioButton.java b/libjava/javax/swing/JRadioButton.java index b1f733acf9e..fc06d15a114 100644 --- a/libjava/javax/swing/JRadioButton.java +++ b/libjava/javax/swing/JRadioButton.java @@ -39,70 +39,219 @@ exception statement from your version. */ package javax.swing; import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; +import javax.swing.plaf.ButtonUI; +/** + * The <code>JRadioButton</code> component provides a visually selectable + * button with mutually exclusive behaviour within a <code>ButtonGroup</code>. + * A series of radio buttons can be used to provide options to the user, + * where the user can only select one of the available options. The state + * of the button is provided by the superclass, <code>JToggleButton</code>. + * <code>JRadioButton</code> adds the additional behaviour, that if two + * or more radio buttons are grouped together, the selection of one implies + * the deselection of the other buttons within the group. + * <p> + * + * Buttons are grouped by adding each instance to a <code>ButtonGroup</code>. + * The existence of such a grouping is not reflected visually, so other means + * should be used to denote this. For instance, the grouped buttons can be placed + * within the same panel, possibly with an appropriate border to denote + * the connection between the components. + * + * @author Michael Koch <konqueror@gmx.de> + * @author Graydon Hoare <graydon@redhat.com> + * @author Andrew John Hughes <gnu_andrew@member.fsf.org> + * @see JToggleButton + * @see ButtonGroup + * @since 1.2 + */ public class JRadioButton extends JToggleButton { + /** + * Compatible with Sun's JDK. + */ private static final long serialVersionUID = 7751949583255506856L; + /** + * This class provides accessibility support for the toggle button. + */ + protected class AccessibleJRadioButton + extends AccessibleJToggleButton + { + + /** + * Constructor for the accessible toggle button. + */ + protected AccessibleJRadioButton() + { + /* Call the superclass to register for events */ + super(); + } + + /** + * Returns the accessible role for the toggle button. + * + * @return An instance of <code>AccessibleRole</code>, describing + * the role of the toggle button. + */ + public AccessibleRole getAccessibleRole() + { + return AccessibleRole.RADIO_BUTTON; + } + + } + + /** + * Constructs an unselected radio button with no text or icon. + */ public JRadioButton() { - this(null, null); + this(null, null, false); } + /** + * Constructs a radio button using the labelling, state + * and icon specified by the supplied action. + * + * @param a the action to use to define the properties of the button. + */ public JRadioButton(Action a) { this(); setAction(a); } + /** + * Constructs an unselected radio button with the supplied icon + * and no text. + * + * @param icon the icon to use. + */ public JRadioButton(Icon icon) { - this(null, icon); + this(null, icon, false); } + /** + * Constructs a radio button with the supplied icon and state. + * + * @param icon the icon to use. + * @param selected if true, the radio button is initially in the + * selected state. Otherwise, the button is unselected. + */ public JRadioButton(Icon icon, boolean selected) { this(null, icon, selected); } + /** + * Constructs an unselected radio button using the supplied text + * and no icon. + * + * @param text the text to use. + */ public JRadioButton(String text) { - this(text, null); + this(text, null, false); } + /** + * Constructs a radio button with the supplied text and state. + * + * @param text the text to use. + * @param selected if true, the radio button is initially in the + * selected state. Otherwise, the button is unselected. + */ public JRadioButton(String text, boolean selected) { this(text, null, selected); } + /** + * Constructs an unselected radio button with the supplied text + * and icon. + * + * @param text the text to use. + * @param icon the icon to use. + */ public JRadioButton(String text, Icon icon) { - super(text, icon); + this(text, icon, false); + } + + /** + * Constructs a radio button with the supplied text, icon and state. + * + * @param text the text to use. + * @param icon the icon to use. + * @param selected if true, the radio button is initially in the + * selected state. Otherwise, the button is unselected. + */ + public JRadioButton(String text, Icon icon, boolean selected) + { + super(text, icon, selected); borderPainted = false; contentAreaFilled = false; } - public JRadioButton(String text, Icon icon, boolean selected) + /** + * Returns the accessible context for this <code>JRadioButton</code>, + * in the form of an instance of <code>AccessibleJRadioButton</code>. + * The context is created, if necessary. + * + * @return the associated context + */ + public AccessibleContext getAccessibleContext() { + /* Create the context if this is the first request */ + if (accessibleContext == null) + { + /* Create the context */ + accessibleContext = new AccessibleJRadioButton(); + } + return accessibleContext; } - - public AccessibleContext getAccessibleContext() - { - //Gets the AccessibleContext associated with this JRadioButton. - return null; - } - public String getUIClassID() - { - //Returns a string that specifies the name of the Look and Feel - //class that renders this component. - return "RadioButtonUI"; - } + /** + * Returns a string specifying the name of the Look and Feel UI class + * that renders this component. + * + * @return the Look and Feel UI class for <code>JRadioButton</code>s + * as a <code>String</code>. + */ + public String getUIClassID() + { + return "RadioButtonUI"; + } - protected String paramString() - { - return "JRadioButton"; - } + /** + * Returns a string representation of this component for debugging use. + * Users should not depend on anything as regards the content or formatting + * of this string, except for the fact that the returned string may never be + * null (only empty). + * + * @return the component in <code>String</code> form for debugging. + */ + protected String paramString() + { + return "JRadioButton"; + } + + /** + * This method resets the radio button's UI delegate to the default UI for + * the current look and feel. + */ + public void updateUI() + { + /* + I can't see any difference between this and the superclass one, + but Sun reimplements it... there is no RadioButtonUI class for it + to be cast to. + */ + setUI((ButtonUI) UIManager.getUI(this)); + } + } diff --git a/libjava/javax/swing/JRadioButtonMenuItem.java b/libjava/javax/swing/JRadioButtonMenuItem.java index 4ced1a595f5..2aefb339546 100644 --- a/libjava/javax/swing/JRadioButtonMenuItem.java +++ b/libjava/javax/swing/JRadioButtonMenuItem.java @@ -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; import java.io.IOException; import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - /** * This class represents JRadioButtonMenuItem. Its behaviour is very similar diff --git a/libjava/javax/swing/JRootPane.java b/libjava/javax/swing/JRootPane.java index 34cd800889e..4f067c9aab9 100644 --- a/libjava/javax/swing/JRootPane.java +++ b/libjava/javax/swing/JRootPane.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; import java.awt.BorderLayout; @@ -44,6 +45,7 @@ import java.awt.Dimension; import java.awt.LayoutManager; import java.awt.LayoutManager2; import java.io.Serializable; + import javax.accessibility.AccessibleRole; import javax.swing.plaf.RootPaneUI; @@ -62,7 +64,9 @@ public class JRootPane extends JComponent // The class used to obtain the accessible role for this object. protected static class AccessibleJRootPane { - /** DOCUMENT ME! */ + /** + * For compatability with Sun's JDK + */ private static final long serialVersionUID = 1082432482784468088L; /** @@ -306,6 +310,16 @@ public class JRootPane extends JComponent /** DOCUMENT ME! */ private static final long serialVersionUID = 8690748000348575668L; + public static final int NONE = 0; + public static final int FRAME = 1; + public static final int PLAIN_DIALOG = 2; + public static final int INFORMATION_DIALOG = 3; + public static final int ERROR_DIALOG = 4; + public static final int COLOR_CHOOSER_DIALOG = 5; + public static final int FILE_CHOOSER_DIALOG = 6; + public static final int QUESTION_DIALOG = 7; + public static final int WARNING_DIALOG = 8; + /** DOCUMENT ME! */ protected Component glassPane; @@ -318,6 +332,8 @@ public class JRootPane extends JComponent /** DOCUMENT ME! */ protected Container contentPane; + protected JButton defaultButton; + /** * DOCUMENT ME! * @@ -466,7 +482,7 @@ public class JRootPane extends JComponent * * @return DOCUMENT ME! */ - protected JComponent createContentPane() + protected Container createContentPane() { JPanel p = new JPanel(); p.setName(this.getName() + ".contentPane"); @@ -538,4 +554,19 @@ public class JRootPane extends JComponent { return "RootPaneUI"; } + + public JButton getDefaultButton() + { + return defaultButton; + } + + public void setDefaultButton(JButton newButton) + { + if (defaultButton == newButton) + return; + + JButton oldButton = defaultButton; + defaultButton = newButton; + firePropertyChange("defaultButton", oldButton, newButton); + } } diff --git a/libjava/javax/swing/JScrollBar.java b/libjava/javax/swing/JScrollBar.java index 07fe5cc8501..b755c6f2a99 100644 --- a/libjava/javax/swing/JScrollBar.java +++ b/libjava/javax/swing/JScrollBar.java @@ -542,7 +542,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible * @param newMin The new minimum. * @param newMax The new maximum. */ - public void setValue(int newValue, int newExtent, int newMin, int newMax) + public void setValues(int newValue, int newExtent, int newMin, int newMax) { if (!isEnabled()) newValue = model.getValue(); diff --git a/libjava/javax/swing/JScrollPane.java b/libjava/javax/swing/JScrollPane.java index 798c48b4b72..01131b7268e 100644 --- a/libjava/javax/swing/JScrollPane.java +++ b/libjava/javax/swing/JScrollPane.java @@ -497,14 +497,14 @@ public class JScrollPane || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) - vsb.setValue(vr.y, vr.height, 0, vs.height); + vsb.setValues(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) - hsb.setValue(vr.x, vr.width, 0, vs.width); + hsb.setValues(vr.x, vr.width, 0, vs.width); } else { @@ -593,7 +593,6 @@ public class JScrollPane return new JViewport(); } - public String getUIClassID() { return "ScrollPaneUI"; @@ -605,6 +604,25 @@ public class JScrollPane setUI(b); } + /** + * This method returns the scrollpane's UI delegate. + * + * @return The scrollpane's UI delegate. + */ + public ScrollPaneUI getUI() + { + return (ScrollPaneUI) ui; + } + + /** + * This method sets the scrollpane's UI delegate. + * + * @param ui The scrollpane's UI delegate. + */ + public void setUI(ScrollPaneUI ui) + { + super.setUI(ui); + } class ScrollBar extends JScrollBar diff --git a/libjava/javax/swing/JSpinner.java b/libjava/javax/swing/JSpinner.java index 00b22d5a670..271c5119f22 100644 --- a/libjava/javax/swing/JSpinner.java +++ b/libjava/javax/swing/JSpinner.java @@ -35,20 +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; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.LayoutManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.DecimalFormat; import java.text.ParseException; -import java.util.EventListener; + import javax.swing.border.EtchedBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -113,21 +111,41 @@ public class JSpinner extends JComponent PropertyChangeListener, LayoutManager { + private JSpinner spinner; + + /** + * For compatability with Sun's JDK 1.4.2 rev. 5 + */ + private static final long serialVersionUID = -5317788736173368172L; + /** - * Creates a new DefaultEditor object. + * Creates a new <code>DefaultEditor</code> object. * - * @param spinner DOCUMENT ME! + * @param spinner the <code>JSpinner</code> associated with this editor */ public DefaultEditor(JSpinner spinner) { + this.spinner = spinner; + spinner.addChangeListener(this); - } /* TODO */ + } + + /** + * Returns the <code>JSpinner</code> object for this editor. + */ + public JSpinner getSpinner() + { + return spinner; + } + /** * DOCUMENT ME! */ public void commitEdit() + throws ParseException { } /* TODO */ + /** * DOCUMENT ME! * @@ -147,6 +165,7 @@ public class JSpinner extends JComponent { return null; } /* TODO */ + /** * DOCUMENT ME! * @@ -155,6 +174,7 @@ public class JSpinner extends JComponent public void layoutContainer(Container parent) { } /* TODO */ + /** * DOCUMENT ME! * @@ -166,6 +186,7 @@ public class JSpinner extends JComponent { return null; } /* TODO */ + /** * DOCUMENT ME! * @@ -177,22 +198,25 @@ public class JSpinner extends JComponent { return null; } /* TODO */ + /** * DOCUMENT ME! * - * @param evt DOCUMENT ME! + * @param event DOCUMENT ME! */ - public void propertyChange(PropertyChangeEvent evt) + public void propertyChange(PropertyChangeEvent event) { } /* TODO */ + /** * DOCUMENT ME! * - * @param evt DOCUMENT ME! + * @param event DOCUMENT ME! */ - public void stateChanged(ChangeEvent evt) + public void stateChanged(ChangeEvent event) { } /* TODO */ + /* no-ops */ public void removeLayoutComponent(Component child) { @@ -215,6 +239,11 @@ public class JSpinner extends JComponent public static class NumberEditor extends DefaultEditor { /** + * For compatability with Sun's JDK + */ + private static final long serialVersionUID = 3791956183098282942L; + + /** * Creates a new NumberEditor object. * * @param spinner DOCUMENT ME! @@ -225,6 +254,16 @@ public class JSpinner extends JComponent } /** + * Creates a new NumberEditor object. + * + * @param spinner DOCUMENT ME! + */ + public NumberEditor(JSpinner spinner, String decimalFormatPattern) + { + super(spinner); + } + + /** * DOCUMENT ME! * * @return DOCUMENT ME! @@ -233,6 +272,11 @@ public class JSpinner extends JComponent { return null; } + + public SpinnerNumberModel getModel() + { + return (SpinnerNumberModel) getSpinner().getModel(); + } } /** DOCUMENT ME! */ @@ -337,6 +381,29 @@ public class JSpinner extends JComponent } /** + * Sets a new underlying model. + * + * @param newModel the new model to set + * + * @exception IllegalArgumentException if newModel is <code>null</code> + */ + public void setModel(SpinnerModel newModel) + { + if (newModel == null) + throw new IllegalArgumentException(); + + if (model == newModel) + return; + + SpinnerModel oldModel = model; + model = newModel; + firePropertyChange("model", oldModel, newModel); + + if (editor == null) + setEditor(createEditor(model)); + } + + /** * Gets the next value without changing the current value. * * @return the next value diff --git a/libjava/javax/swing/JSplitPane.java b/libjava/javax/swing/JSplitPane.java index 32b85e1da95..9cdad16a7cf 100644 --- a/libjava/javax/swing/JSplitPane.java +++ b/libjava/javax/swing/JSplitPane.java @@ -40,15 +40,14 @@ package javax.swing; import java.awt.Component; import java.awt.Graphics; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleStateSet; import javax.accessibility.AccessibleValue; -import javax.swing.UIManager; import javax.swing.plaf.SplitPaneUI; - /** * This class implements JSplitPane. It is used to divide two components. By * dragging the SplitPane's divider, the user can resize the two components. diff --git a/libjava/javax/swing/JTabbedPane.java b/libjava/javax/swing/JTabbedPane.java index 0f3fbce8b70..25733df4a79 100644 --- a/libjava/javax/swing/JTabbedPane.java +++ b/libjava/javax/swing/JTabbedPane.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; import java.awt.Color; @@ -44,6 +45,7 @@ import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.io.Serializable; import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -53,7 +55,6 @@ import javax.swing.event.ChangeListener; import javax.swing.plaf.TabbedPaneUI; import javax.swing.plaf.UIResource; - /** * <p> * This is a container for components. One component is displayed at a time. diff --git a/libjava/javax/swing/JTable.java b/libjava/javax/swing/JTable.java index 4a81e0400cd..ae2c4af5fb5 100644 --- a/libjava/javax/swing/JTable.java +++ b/libjava/javax/swing/JTable.java @@ -56,8 +56,8 @@ import javax.swing.event.TableColumnModelListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.plaf.TableUI; -import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; @@ -675,6 +675,11 @@ public class JTable extends JComponent return renderer; } + public void setDefaultRenderer(Class columnClass, TableCellRenderer rend) + { + defaultRenderersByColumnClass.put(columnClass, rend); + } + public TableCellRenderer getDefaultRenderer(Class columnClass) { if (defaultRenderersByColumnClass.containsKey(columnClass)) @@ -1148,16 +1153,32 @@ public class JTable extends JComponent */ public void setModel(TableModel m) { + // Throw exception is m is null. if (m == null) throw new IllegalArgumentException(); - TableModel tmp = dataModel; - if (autoCreateColumnsFromModel) - createColumnsFromModel(); - if (tmp != null) - tmp.removeTableModelListener(this); + + // Don't do anything if setting the current model again. + if (dataModel == m) + return; + + // Remove table as TableModelListener from old model. + if (dataModel != null) + dataModel.removeTableModelListener(this); + if (m != null) - m.addTableModelListener(this); - dataModel = m; + { + // Set property. + dataModel = m; + + // Add table as TableModelListener to new model. + dataModel.addTableModelListener(this); + + // Automatically create columns. + if (autoCreateColumnsFromModel) + createColumnsFromModel(); + } + + // Repaint table. revalidate(); repaint(); } @@ -1540,17 +1561,31 @@ public class JTable extends JComponent doLayout(); } - public String getUIClassID() { return "TableUI"; } + /** + * This method returns the table's UI delegate. + * + * @return The table's UI delegate. + */ public TableUI getUI() { return (TableUI) ui; } + /** + * This method sets the table's UI delegate. + * + * @param ui The table's UI delegate. + */ + public void setUI(TableUI ui) + { + super.setUI(ui); + } + public void updateUI() { setUI((TableUI) UIManager.getUI(this)); diff --git a/libjava/javax/swing/JTextArea.java b/libjava/javax/swing/JTextArea.java index 5cbc87dcdc4..2561775286b 100644 --- a/libjava/javax/swing/JTextArea.java +++ b/libjava/javax/swing/JTextArea.java @@ -35,22 +35,86 @@ 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; -import java.awt.Dimension; +import java.awt.FontMetrics; + +import javax.swing.text.BadLocationException; import javax.swing.text.Document; +import javax.swing.text.Element; import javax.swing.text.JTextComponent; import javax.swing.text.PlainDocument; +/** + * The <code>JTextArea</code> component provides a multi-line area for displaying + * and editing plain text. The component is designed to act as a lightweight + * replacement for the heavyweight <code>java.awt.TextArea</code> component, + * which provides similar functionality using native widgets. + * <p> + * + * This component has additional functionality to the AWT class. It follows + * the same design pattern as seen in other text components, such as + * <code>JTextField</code>, <code>JTextPane</code> and <code>JEditorPane</code>, + * and embodied in <code>JTextComponent</code>. These classes separate the text + * (the model) from its appearance within the onscreen component (the view). The + * text is held within a <code>javax.swing.text.Document</code> object, which can + * also maintain relevant style information where necessary. As a result, it is the + * document that should be monitored for textual changes, via + * <code>DocumentEvent</code>s delivered to registered + * <code>DocumentListener</code>s, rather than this component. + * <p> + * + * Unlike <code>java.awt.TextArea</code>, <code>JTextArea</code> does not + * handle scrolling. Instead, this functionality is delegated to a + * <code>JScrollPane</code>, which can contain the text area and handle + * scrolling when required. Likewise, the word wrapping functionality + * of the AWT component is converted to a property of this component + * and the <code>rows</code> and <code>columns</code> properties + * are used in calculating the preferred size of the scroll pane's + * view port. + * + * @author Michael Koch <konqueror@gmx.de> + * @author Andrew John Hughes <gnu_andrew@member.fsf.org> + * @see java.awt.TextArea + * @see javax.swing.JTextComponent + * @see javax.swing.JTextField + * @see javax.swing.JTextPane + * @see javax.swing.JEditorPane + * @see javax.swing.text.Document + * @see javax.swing.text.DocumentEvent + * @see javax.swing.text.DocumentListener + */ + public class JTextArea extends JTextComponent { + /** + * Compatible with Sun's JDK + */ private static final long serialVersionUID = -6141680179310439825L; + /** + * The number of rows used by the component. + */ private int rows; + + /** + * The number of columns used by the component. + */ private int columns; - private boolean wrapping; + + /** + * Whether line wrapping is enabled or not. + */ + private boolean lineWrap; + + /** + * The number of characters equal to a tab within the text. + */ private int tabSize = 8; + private boolean wrapStyleWord; + /** * Creates a new <code>JTextArea</code> object. */ @@ -125,13 +189,22 @@ public class JTextArea extends JTextComponent } /** - * Appends some text. + * Appends the supplied text to the current contents + * of the document model. * * @param toAppend the text to append */ public void append(String toAppend) { - setText(getText() + toAppend); + try + { + getDocument().insertString(getText().length(), toAppend, null); + } + catch (BadLocationException exception) + { + /* This shouldn't happen in theory -- but, if it does... */ + throw new RuntimeException("Unexpected exception occurred.", exception); + } } /** @@ -144,10 +217,16 @@ public class JTextArea extends JTextComponent return new PlainDocument(); } - + /** + * Returns true if the width of this component should be forced + * to match the width of a surrounding view port. When line wrapping + * is turned on, this method returns true. + * + * @return true if lines are wrapped. + */ public boolean getScrollableTracksViewportWidth() { - return wrapping ? true : super.getScrollableTracksViewportWidth(); + return lineWrap ? true : super.getScrollableTracksViewportWidth(); } /** @@ -211,35 +290,78 @@ public class JTextArea extends JTextComponent } /** - * Checks whethet line wrapping is enabled. + * Checks whether line wrapping is enabled. * - * @return true if line wrapping is enabled, false otherwise + * @return <code>true</code> if line wrapping is enabled, + * <code>false</code> otherwise */ public boolean getLineWrap() { - return wrapping; + return lineWrap; } /** * Enables/disables line wrapping. * - * @param wrapping true to enable line wrapping, false otherwise + * @param wrapping <code>true</code> to enable line wrapping, + * <code>false</code> otherwise */ public void setLineWrap(boolean flag) { - if (wrapping == flag) + if (lineWrap == flag) return; - boolean oldValue = wrapping; - wrapping = flag; - firePropertyChange("lineWrap", oldValue, wrapping); + boolean oldValue = lineWrap; + lineWrap = flag; + firePropertyChange("lineWrap", oldValue, lineWrap); } + /** + * Checks whether word style wrapping is enabled. + * + * @return <code>true</code> if word style wrapping is enabled, + * <code>false</code> otherwise + */ + public boolean getWrapStyleWord() + { + return wrapStyleWord; + } + + /** + * Enables/Disables word style wrapping. + * + * @param flag <code>true</code> to enable word style wrapping, + * <code>false</code> otherwise + */ + public void setWrapStyleWord(boolean flag) + { + if (wrapStyleWord == flag) + return; + + boolean oldValue = wrapStyleWord; + wrapStyleWord = flag; + firePropertyChange("wrapStyleWord", oldValue, wrapStyleWord); + } + + /** + * Returns the number of characters used for a tab. + * This defaults to 8. + * + * @return the current number of spaces used for a tab. + */ public int getTabSize() { return tabSize; } + /** + * Sets the number of characters used for a tab to the + * supplied value. If a change to the tab size property + * occurs (i.e. newSize != tabSize), a property change event + * is fired. + * + * @param newSize The new number of characters to use for a tab. + */ public void setTabSize(int newSize) { if (tabSize == newSize) @@ -249,4 +371,110 @@ public class JTextArea extends JTextComponent tabSize = newSize; firePropertyChange("tabSize", oldValue, tabSize); } + + protected int getColumnWidth() + { + FontMetrics metrics = getToolkit().getFontMetrics(getFont()); + return metrics.charWidth('m'); + } + + public int getLineCount() + { + return getDocument().getDefaultRootElement().getElementCount(); + } + + public int getLineStartOffset(int line) + throws BadLocationException + { + int lineCount = getLineCount(); + + if (line < 0 || line > lineCount) + throw new BadLocationException("Non-existing line number", line); + + Element lineElem = getDocument().getDefaultRootElement().getElement(line); + return lineElem.getStartOffset(); + } + + public int getLineEndOffset(int line) + throws BadLocationException + { + int lineCount = getLineCount(); + + if (line < 0 || line > lineCount) + throw new BadLocationException("Non-existing line number", line); + + Element lineElem = getDocument().getDefaultRootElement().getElement(line); + return lineElem.getEndOffset(); + } + + public int getLineOfOffset(int offset) + throws BadLocationException + { + Document doc = getDocument(); + + if (offset < doc.getStartPosition().getOffset() + || offset >= doc.getEndPosition().getOffset()) + throw new BadLocationException("offset outside of document", offset); + + return doc.getDefaultRootElement().getElementIndex(offset); + } + + protected int getRowHeight() + { + FontMetrics metrics = getToolkit().getFontMetrics(getFont()); + return metrics.getHeight(); + } + + /** + * Inserts the supplied text at the specified position. Nothing + * happens in the case that the model or the supplied string is null + * or of zero length. + * + * @param string The string of text to insert. + * @param position The position at which to insert the supplied text. + * @throws IllegalArgumentException if the position is < 0 or greater + * than the length of the current text. + */ + public void insert(String string, int position) + { + // Retrieve the document model. + Document doc = getDocument(); + + // Check the model and string for validity. + if (doc == null + || string == null + || string.length() == 0) + return; + + // Insert the text into the model. + try + { + doc.insertString(position, string, null); + } + catch (BadLocationException e) + { + throw new IllegalArgumentException("The supplied position, " + + position + ", was invalid."); + } + } + + public void replaceRange(String text, int start, int end) + { + Document doc = getDocument(); + + if (start > end + || start < doc.getStartPosition().getOffset() + || end >= doc.getEndPosition().getOffset()) + throw new IllegalArgumentException(); + + try + { + doc.remove(start, end); + doc.insertString(start, text, null); + } + catch (BadLocationException e) + { + // This cannot happen as we check offset above. + } + } } diff --git a/libjava/javax/swing/JTextField.java b/libjava/javax/swing/JTextField.java index 4466f5ad5b3..5fe104b5093 100644 --- a/libjava/javax/swing/JTextField.java +++ b/libjava/javax/swing/JTextField.java @@ -42,6 +42,9 @@ import java.awt.Font; import java.awt.FontMetrics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + import javax.accessibility.AccessibleStateSet; import javax.swing.text.Document; import javax.swing.text.JTextComponent; @@ -83,6 +86,16 @@ public class JTextField extends JTextComponent private int align; + private int scrollOffset; + + /** @since 1.3 */ + private Action action; + + /** @since 1.3 */ + private String actionCommand; + + private PropertyChangeListener actionPropertyChangeListener; + /** * Creates a new instance of <code>JTextField</code>. */ @@ -241,11 +254,14 @@ public class JTextField extends JTextComponent public void setHorizontalAlignment(int newAlign) { + if (align == newAlign) + return; + int oldAlign = align; align = newAlign; + firePropertyChange("horizontalAlignment", oldAlign, newAlign); invalidate(); repaint(); - firePropertyChange("horizontalAlignment", oldAlign, newAlign); } public void setFont(Font newFont) @@ -272,4 +288,134 @@ public class JTextField extends JTextComponent return size; } + + /** + * Returns the scroll offset in pixels. + * + * @return the scroll offset + */ + public int getScrollOffset() + { + return scrollOffset; + } + + /** + * Sets the scroll offset in pixels. + * + * @param offset the scroll offset + */ + public void setScrollOffset(int offset) + { + scrollOffset = offset; + } + + public void postActionEvent() + { + ActionEvent event = new ActionEvent(this, 0, actionCommand); + ActionListener[] listeners = getActionListeners(); + + for (int index = 0; index < listeners.length; ++index) + listeners[index].actionPerformed(event); + } + + /** + * @since 1.3 + */ + public Action getAction() + { + return action; + } + + /** + * @since 1.3 + */ + public void setAction(Action newAction) + { + if (action == newAction) + return; + + if (action != null) + { + removeActionListener(action); + action.removePropertyChangeListener(actionPropertyChangeListener); + actionPropertyChangeListener = null; + } + + Action oldAction = action; + action = newAction; + + if (action != null) + { + addActionListener(action); + actionPropertyChangeListener = + createActionPropertyChangeListener(action); + action.addPropertyChangeListener(actionPropertyChangeListener); + } + + firePropertyChange("horizontalAlignment", oldAction, newAction); + } + + /** + * @since 1.3 + */ + public String getActionCommand() + { + return actionCommand; + } + + /** + * @since 1.3 + */ + public void setActionCommand(String command) + { + this.actionCommand = command; + } + + /** + * @since 1.3 + */ + protected PropertyChangeListener createActionPropertyChangeListener(Action action) + { + return new PropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + // Update properties "action" and "horizontalAlignment". + String name = event.getPropertyName(); + + if (name.equals("enabled")) + { + boolean enabled = ((Boolean) event.getNewValue()).booleanValue(); + JTextField.this.setEnabled(enabled); + } + else if (name.equals(Action.SHORT_DESCRIPTION)) + { + JTextField.this.setToolTipText((String) event.getNewValue()); + } + } + }; + } + + /** + * @since 1.3 + */ + protected void configurePropertiesFromAction(Action action) + { + if (action != null) + { + setEnabled(action.isEnabled()); + setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION)); + } + else + { + setEnabled(true); + setToolTipText(null); + } + } + + protected int getColumnWidth() + { + FontMetrics metrics = getToolkit().getFontMetrics(getFont()); + return metrics.charWidth('m'); + } } diff --git a/libjava/javax/swing/JTextPane.java b/libjava/javax/swing/JTextPane.java index d1bd473de2d..95d2d50015a 100644 --- a/libjava/javax/swing/JTextPane.java +++ b/libjava/javax/swing/JTextPane.java @@ -35,11 +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; import java.awt.Component; import java.io.IOException; import java.io.ObjectOutputStream; + import javax.swing.text.AttributeSet; import javax.swing.text.Document; import javax.swing.text.EditorKit; diff --git a/libjava/javax/swing/JToggleButton.java b/libjava/javax/swing/JToggleButton.java index c04bcc36739..8a38d48d3aa 100644 --- a/libjava/javax/swing/JToggleButton.java +++ b/libjava/javax/swing/JToggleButton.java @@ -38,17 +38,103 @@ exception statement from your version. */ package javax.swing; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; +import javax.accessibility.AccessibleState; import javax.swing.plaf.ButtonUI; +/** + * The <code>JToggleButton</code> component provides a stateful button, + * which can be either selected or unselected. This provides the basis + * for the implementations of radio buttons (<code>JRadioButton</code>) + * and check boxes (<code>JCheckBox</code>). + * + * @author Michael Koch <konqueror@gmx.de> + * @author Graydon Hoare <graydon@redhat.com> + * @author Andrew John Hughes <gnu_andrew@member.fsf.org> + * @see JRadioButton + * @see JCheckBox + * @since 1.2 + */ public class JToggleButton extends AbstractButton implements Accessible { + + /** + * This class provides accessibility support for the toggle button. + */ + protected class AccessibleJToggleButton + extends AccessibleAbstractButton + implements ItemListener + { + + /** + * Constructor for the accessible toggle button. + */ + public AccessibleJToggleButton() + { + super(); + /* Register the accessible toggle button as a listener for item events */ + addItemListener(this); + } + + /** + * Returns the accessible role for the toggle button. + * + * @return An instance of <code>AccessibleRole</code>, describing + * the role of the toggle button. + */ + public AccessibleRole getAccessibleRole() + { + return AccessibleRole.TOGGLE_BUTTON; + } + + /** + * Monitors the toggle button for state changes and fires accessible + * property change events when they occur. + * + * @param event the event that occurred. + */ + public void itemStateChanged(ItemEvent event) + { + /* Fire a state property change event as the button's state has changed */ + if (event.getStateChange() == ItemEvent.SELECTED) + { + /* State has changed from unselected (null) to selected */ + firePropertyChange(ACCESSIBLE_STATE_PROPERTY, null, AccessibleState.SELECTED); + } + else + { + /* State has changed from selected to unselected (null) */ + firePropertyChange(ACCESSIBLE_STATE_PROPERTY, AccessibleState.ENABLED, null); + } + } + + } + /** + * The model handles the storage and maintenance of the state of + * the toggle button. This follows the same paradigm (the MVC + * or Model-View-Controller design pattern) employed by + * other Swing components, where the data associated with a component + * is stored separately from the display aspects. + */ public static class ToggleButtonModel extends DefaultButtonModel { + /** + * Compatible with Sun's JDK. + */ private static final long serialVersionUID = -1589950750899943974L; + /** + * Sets the pressed state of the button. The selected state + * of the button also changes follwing the button being pressed. + * + * @param b true if the button is pressed down. + */ public void setPressed(boolean b) { if (! isEnabled()) @@ -63,44 +149,97 @@ public class JToggleButton extends AbstractButton implements Accessible } } - + /** + * Compatible with Sun's JDK. + */ private static final long serialVersionUID = -3128248873429850443L; + /** + * Constructs an unselected toggle button with no text or icon. + */ public JToggleButton() { - this(null, null); + this(null, null, false); } + + /** + * Constructs a toggle button using the labelling, state + * and icon specified by the supplied action. + * + * @param a the action to use to define the properties of the button. + */ public JToggleButton(Action a) { this(); setAction(a); } + /** + * Constructs an unselected toggle button with the supplied icon + * and no text. + * + * @param icon the icon to use. + */ public JToggleButton(Icon icon) { - this(null, icon); + this(null, icon, false); } - public JToggleButton (Icon icon, boolean selected) + /** + * Constructs a toggle button with the supplied icon and state. + * + * @param icon the icon to use. + * @param selected if true, the toggle button is initially in the + * selected state. Otherwise, the button is unselected. + */ + public JToggleButton(Icon icon, boolean selected) { this(null, icon, selected); } + /** + * Constructs an unselected toggle button using the supplied text + * and no icon. + * + * @param text the text to use. + */ public JToggleButton(String text) { - this(text, null); + this(text, null, false); } + /** + * Constructs a toggle button with the supplied text and state. + * + * @param text the text to use. + * @param selected if true, the toggle button is initially in the + * selected state. Otherwise, the button is unselected. + */ public JToggleButton(String text, boolean selected) { this(text, null, selected); } + /** + * Constructs an unselected toggle button with the supplied text + * and icon. + * + * @param text the text to use. + * @param icon the icon to use. + */ public JToggleButton(String text, Icon icon) { this(text, icon, false); } + /** + * Constructs a toggle button with the supplied text, icon and state. + * + * @param text the text to use. + * @param icon the icon to use. + * @param selected if true, the toggle button is initially in the + * selected state. Otherwise, the button is unselected. + */ public JToggleButton (String text, Icon icon, boolean selected) { super(text, icon); @@ -112,34 +251,54 @@ public class JToggleButton extends AbstractButton implements Accessible /** * Gets the AccessibleContext associated with this <code>JToggleButton</code>. + * The context is created, if necessary. * * @return the associated context */ public AccessibleContext getAccessibleContext() { - return null; + /* Create the context if this is the first request */ + if (accessibleContext == null) + { + /* Create the context */ + accessibleContext = new AccessibleJToggleButton(); + } + return accessibleContext; } /** * Returns a string that specifies the name of the Look and Feel * class that renders this component. + * + * @return The Look and Feel UI class in <code>String</code> form. */ public String getUIClassID() { return "ToggleButtonUI"; } + /** + * Returns a textual representation of this component for debugging. + * Users should not depend on anything as regards the content or formatting + * of this string, except for the fact that the returned string may never be + * null (only empty). + * + * @return the component in <code>String</code> form for debugging. + */ protected String paramString() { return "JToggleButton"; } - + /** + * This method resets the toggle button's UI delegate to the default UI for + * the current look and feel. + */ public void updateUI() { - ButtonUI b = (ButtonUI)UIManager.getUI(this); - setUI(b); + setUI((ButtonUI)UIManager.getUI(this)); } + } diff --git a/libjava/javax/swing/JToolBar.java b/libjava/javax/swing/JToolBar.java index 7b5121e76fc..db8bb569e9f 100644 --- a/libjava/javax/swing/JToolBar.java +++ b/libjava/javax/swing/JToolBar.java @@ -35,25 +35,23 @@ 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; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Graphics; -import java.awt.GridLayout; import java.awt.Insets; import java.awt.LayoutManager; import java.beans.PropertyChangeListener; -import java.io.IOException; -import java.io.ObjectOutputStream; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleStateSet; import javax.swing.plaf.ToolBarUI; - /** * JToolBar is a component that provides a toolbar to Swing programs. Users * can add buttons (or actions that will be represented by JButtons) as well diff --git a/libjava/javax/swing/JToolTip.java b/libjava/javax/swing/JToolTip.java index daf9f0a21e5..8099ef9387b 100644 --- a/libjava/javax/swing/JToolTip.java +++ b/libjava/javax/swing/JToolTip.java @@ -35,15 +35,16 @@ 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; import java.awt.AWTEvent; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.plaf.ToolTipUI; - /** * This class is used to display ToolTips. ToolTips are small floating windows * that display text when the mouse comes to rest over a Component. ToolTips diff --git a/libjava/javax/swing/JTree.java b/libjava/javax/swing/JTree.java index 4e81bff8422..8d52257c536 100644 --- a/libjava/javax/swing/JTree.java +++ b/libjava/javax/swing/JTree.java @@ -35,12 +35,16 @@ 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; import java.awt.Dimension; import java.awt.Rectangle; +import java.util.Enumeration; import java.util.Hashtable; +import java.util.Iterator; import java.util.Vector; + import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.event.TreeExpansionEvent; @@ -50,10 +54,15 @@ import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeWillExpandListener; import javax.swing.plaf.TreeUI; import javax.swing.tree.ExpandVetoException; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeCellEditor; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; public class JTree extends JComponent @@ -61,18 +70,43 @@ public class JTree extends JComponent { private static final long serialVersionUID = 7559816092864483649L; + public static final String ANCHOR_SELECTION_PATH_PROPERTY = "anchorSelectionPath"; + public static final String CELL_EDITOR_PROPERTY = "cellEditor"; + public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; + public static final String EDITABLE_PROPERTY = "editable"; + public static final String EXPANDS_SELECTED_PATHS_PROPERTY = "expandsSelectedPaths"; + public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "invokesStopCellEditing"; + public static final String LARGE_MODEL_PROPERTY = "largeModel"; + public static final String LEAD_SELECTION_PATH_PROPERTY = "leadSelectionPath"; + public static final String ROOT_VISIBLE_PROPERTY = "rootVisible"; + public static final String ROW_HEIGHT_PROPERTY = "rowHeight"; + public static final String SCROLLS_ON_EXPAND_PROPERTY = "scrollsOnExpand"; + public static final String SELECTION_MODEL_PROPERTY = "selectionModel"; + public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles"; + public static final String TOGGLE_CLICK_COUNT_PROPERTY = "toggleClickCount"; + public static final String TREE_MODEL_PROPERTY = "model"; + public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount"; + + protected TreeCellEditor cellEditor; protected TreeCellRenderer cellRenderer; protected boolean editable; + protected boolean invokesStopCellEditing; + protected boolean largeModel; protected boolean rootVisible; + protected int rowHeight; + protected boolean scrollsOnExpand; + protected TreeSelectionModel selectionModel; protected boolean showsRootHandles; + protected int toggleClickCount; protected TreeModel treeModel; + protected int visibleRowCount; /** * Creates a new <code>JTree</code> object. */ public JTree() { - treeModel = createTreeModel(null); + this(createTreeModel(null)); } /** @@ -82,7 +116,7 @@ public class JTree extends JComponent */ public JTree(Hashtable value) { - treeModel = createTreeModel(value); + this(createTreeModel(value)); } /** @@ -92,7 +126,7 @@ public class JTree extends JComponent */ public JTree(Object[] value) { - treeModel = createTreeModel(value); + this(createTreeModel(value)); } /** @@ -103,6 +137,8 @@ public class JTree extends JComponent public JTree(TreeModel model) { treeModel = model; + setCellRenderer(new DefaultTreeCellRenderer()); + updateUI(); } /** @@ -124,6 +160,7 @@ public class JTree extends JComponent */ public JTree(TreeNode root, boolean asksAllowChildren) { + this(new DefaultTreeModel(root, asksAllowChildren)); } /** @@ -133,7 +170,81 @@ public class JTree extends JComponent */ public JTree(Vector value) { - treeModel = createTreeModel(value); + this(createTreeModel(value)); + } + + public static class DynamicUtilTreeNode + extends DefaultMutableTreeNode + { + protected Object childValue; + protected boolean loadedChildren; + public DynamicUtilTreeNode(Object value, + Object children) + { + super(value); + childValue = children; + loadedChildren = false; + } + + public int getChildCount() + { + loadChildren(); + return super.getChildCount(); + } + + protected void loadChildren() + { + if (!loadedChildren) + { + createChildren(this, childValue); + loadedChildren = true; + } + } + + public Enumeration children() + { + loadChildren(); + return super.children(); + } + + public boolean isLeaf() + { + return (childValue == null || + !(childValue instanceof Hashtable + || childValue instanceof Vector + || childValue.getClass().isArray())); + } + + public static void createChildren(DefaultMutableTreeNode parent, + Object children) + { + if (children instanceof Hashtable) + { + Hashtable tab = (Hashtable) children; + Enumeration e = tab.keys(); + while (e.hasMoreElements()) + { + Object key = e.nextElement(); + Object val = tab.get(key); + parent.add(new DynamicUtilTreeNode(key, val)); + } + } + else if (children instanceof Vector) + { + Iterator i = ((Vector)children).iterator(); + while (i.hasNext()) + { + Object n = i.next(); + parent.add(new DynamicUtilTreeNode(n,n)); + } + } + else if (children.getClass().isArray()) + { + Object[] arr = (Object[]) children; + for (int i = 0; i < arr.length; ++i) + parent.add(new DynamicUtilTreeNode(arr[i], arr[i])); + } + } } /** @@ -143,8 +254,7 @@ public class JTree extends JComponent */ protected static TreeModel createTreeModel(Object value) { - // FIXME: Implement this. - return null; + return new DefaultTreeModel(new DynamicUtilTreeNode(value, value)); } /** @@ -173,6 +283,8 @@ public class JTree extends JComponent public void updateUI() { setUI((TreeUI) UIManager.getUI(this)); + revalidate(); + repaint(); } /** @@ -441,7 +553,7 @@ public class JTree extends JComponent * @return <code>true</code> if the root element is visible, * <code>false</code> otherwise */ - public boolean isRootVisbile() + public boolean isRootVisible() { return rootVisible; } @@ -456,11 +568,21 @@ public class JTree extends JComponent return showsRootHandles; } - public void setShowRootHandles(boolean flag) + public void setShowsRootHandles(boolean flag) { showsRootHandles = flag; } + public TreeCellEditor getCellEditor() + { + return cellEditor; + } + + public void setCellEditor(TreeCellEditor editor) + { + cellEditor = editor; + } + public TreeCellRenderer getCellRenderer() { return cellRenderer; @@ -470,4 +592,80 @@ public class JTree extends JComponent { cellRenderer = newRenderer; } + + public TreeSelectionModel getSelectionModel() + { + return selectionModel; + } + + public void setSelectionModel(TreeSelectionModel model) + { + selectionModel = model; + } + + public int getVisibleRowCount() + { + return visibleRowCount; + } + + public void setVisibleRowCount(int rows) + { + visibleRowCount = rows; + } + + public boolean isLargeModel() + { + return largeModel; + } + + public void setLargeModel(boolean large) + { + largeModel = large; + } + + public int getRowHeight() + { + return rowHeight; + } + + public void setRowHeight(int height) + { + rowHeight = height; + } + + public boolean getInvokesStopCellEditing() + { + return invokesStopCellEditing; + } + + public void setInvokesStopCellEditing(boolean invoke) + { + invokesStopCellEditing = invoke; + } + + /** + * @since 1.3 + */ + public int getToggleClickCount() + { + return toggleClickCount; + } + + /** + * @since 1.3 + */ + public void setToggleClickCount(int count) + { + toggleClickCount = count; + } + + public boolean getScrollsOnExpand() + { + return scrollsOnExpand; + } + + public void setScrollsOnExpand(boolean scroll) + { + scrollsOnExpand = scroll; + } } diff --git a/libjava/javax/swing/JViewport.java b/libjava/javax/swing/JViewport.java index a36118371ce..9b26c8b21af 100644 --- a/libjava/javax/swing/JViewport.java +++ b/libjava/javax/swing/JViewport.java @@ -45,12 +45,10 @@ import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; -import javax.accessibility.Accessible; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.ViewportUI; - /** * * <pre> @@ -129,6 +127,7 @@ public class JViewport extends JComponent public JViewport() { setOpaque(true); + setScrollMode(BLIT_SCROLL_MODE); updateUI(); } @@ -214,11 +213,17 @@ public class JViewport extends JComponent getExtentSize()); } + /** + * @deprecated 1.4 + */ public boolean isBackingStoreEnabled() { return scrollMode == BACKINGSTORE_SCROLL_MODE; } + /** + * @deprecated 1.4 + */ public void setBackingStoreEnabled(boolean b) { if (b && scrollMode != BACKINGSTORE_SCROLL_MODE) @@ -305,23 +310,11 @@ public class JViewport extends JComponent return false; } - public ChangeListener[] getChangeListeners() - { - return (ChangeListener[]) getListeners(ChangeListener.class); - } - public void paint(Graphics g) { paintComponent(g); } - void fireStateChanged() - { - ChangeListener[] listeners = getChangeListeners(); - for (int i = 0; i < listeners.length; ++i) - listeners[i].stateChanged(changeEvent); - } - public void addChangeListener(ChangeListener listener) { listenerList.add(ChangeListener.class, listener); @@ -332,6 +325,18 @@ public class JViewport extends JComponent listenerList.remove(ChangeListener.class, listener); } + public ChangeListener[] getChangeListeners() + { + return (ChangeListener[]) getListeners(ChangeListener.class); + } + + protected void fireStateChanged() + { + ChangeListener[] listeners = getChangeListeners(); + for (int i = 0; i < listeners.length; ++i) + listeners[i].stateChanged(changeEvent); + } + /** * This method returns the String ID of the UI class of Separator. * @@ -349,4 +354,24 @@ public class JViewport extends JComponent { setUI((ViewportUI) UIManager.getUI(this)); } + + /** + * This method returns the viewport's UI delegate. + * + * @return The viewport's UI delegate. + */ + public ViewportUI getUI() + { + return (ViewportUI) ui; + } + + /** + * This method sets the viewport's UI delegate. + * + * @param ui The viewport's UI delegate. + */ + public void setUI(ViewportUI ui) + { + super.setUI(ui); + } } diff --git a/libjava/javax/swing/JWindow.java b/libjava/javax/swing/JWindow.java index c035a1bd9cc..3601b694105 100644 --- a/libjava/javax/swing/JWindow.java +++ b/libjava/javax/swing/JWindow.java @@ -62,10 +62,10 @@ public class JWindow extends Window implements Accessible, RootPaneContainer { private static final long serialVersionUID = 5420698392125238833L; - public final static int HIDE_ON_CLOSE = 0; - public final static int EXIT_ON_CLOSE = 1; - public final static int DISPOSE_ON_CLOSE = 2; - public final static int DO_NOTHING_ON_CLOSE = 3; + public static final int HIDE_ON_CLOSE = 0; + public static final int EXIT_ON_CLOSE = 1; + public static final int DISPOSE_ON_CLOSE = 2; + public static final int DO_NOTHING_ON_CLOSE = 3; protected AccessibleContext accessibleContext; diff --git a/libjava/javax/swing/ListModel.java b/libjava/javax/swing/ListModel.java index 1aa7bd20619..405df0e65a7 100644 --- a/libjava/javax/swing/ListModel.java +++ b/libjava/javax/swing/ListModel.java @@ -36,6 +36,7 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.swing; + import javax.swing.event.ListDataListener; /** diff --git a/libjava/javax/swing/LookAndFeel.java b/libjava/javax/swing/LookAndFeel.java index dc28065c373..3a56a114943 100644 --- a/libjava/javax/swing/LookAndFeel.java +++ b/libjava/javax/swing/LookAndFeel.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; import java.awt.Component; import java.awt.Toolkit; -import javax.swing.text.JTextComponent; +import javax.swing.text.JTextComponent; public abstract class LookAndFeel { diff --git a/libjava/javax/swing/MenuSelectionManager.java b/libjava/javax/swing/MenuSelectionManager.java index a61ca4ec51a..2e93c01e934 100644 --- a/libjava/javax/swing/MenuSelectionManager.java +++ b/libjava/javax/swing/MenuSelectionManager.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; import java.awt.Component; @@ -44,13 +45,11 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Vector; -import javax.swing.JMenu; -import javax.swing.JMenuItem; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; - /** * This class manages current menu selectection. It provides * methods to clear and set current selected menu path. diff --git a/libjava/javax/swing/ProgressMonitorInputStream.java b/libjava/javax/swing/ProgressMonitorInputStream.java index 48802c3f895..56ae3bcf772 100644 --- a/libjava/javax/swing/ProgressMonitorInputStream.java +++ b/libjava/javax/swing/ProgressMonitorInputStream.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; import java.awt.Component; import java.io.FilterInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; /** * ProgressMonitorInputStream diff --git a/libjava/javax/swing/RepaintManager.java b/libjava/javax/swing/RepaintManager.java index 8910bf58301..1c9208e7a3b 100644 --- a/libjava/javax/swing/RepaintManager.java +++ b/libjava/javax/swing/RepaintManager.java @@ -1,5 +1,5 @@ /* RepaintManager.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + 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; import java.awt.Component; @@ -42,13 +43,12 @@ import java.awt.Dimension; import java.awt.Image; import java.awt.Rectangle; import java.util.Enumeration; -import java.util.Hashtable; import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Vector; - /** * <p>The repaint manager holds a set of dirty regions, invalid components, * and a double buffer surface. The dirty regions and invalid components @@ -309,6 +309,9 @@ public class RepaintManager public synchronized void addDirtyRegion(JComponent component, int x, int y, int w, int h) { + if (w == 0 || h == 0) + return; + Rectangle r = new Rectangle(x, y, w, h); if (dirtyComponents.containsKey(component)) r = r.union((Rectangle)dirtyComponents.get(component)); diff --git a/libjava/javax/swing/RootPaneContainer.java b/libjava/javax/swing/RootPaneContainer.java index c571eb8c9b4..d2eff356cba 100644 --- a/libjava/javax/swing/RootPaneContainer.java +++ b/libjava/javax/swing/RootPaneContainer.java @@ -35,10 +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; -import java.awt.Container; import java.awt.Component; +import java.awt.Container; /** * RootPaneContainer diff --git a/libjava/javax/swing/ScrollPaneLayout.java b/libjava/javax/swing/ScrollPaneLayout.java index 1103f3f8b64..0da8f18e549 100644 --- a/libjava/javax/swing/ScrollPaneLayout.java +++ b/libjava/javax/swing/ScrollPaneLayout.java @@ -43,9 +43,10 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.Insets; import java.awt.LayoutManager; -import java.awt.Rectangle; import java.awt.Point; +import java.awt.Rectangle; import java.io.Serializable; + import javax.swing.border.Border; /** @@ -320,7 +321,6 @@ public class ScrollPaneLayout insetsSize.setSize(insets.left + insets.right, insets.top + insets.bottom); - maybeSetMinimumSize(viewport, viewportSize); maybeSetMinimumSize(colHead, columnHeaderSize); maybeSetMinimumSize(rowHead, rowHeaderSize); diff --git a/libjava/javax/swing/SpinnerListModel.java b/libjava/javax/swing/SpinnerListModel.java new file mode 100644 index 00000000000..4da26146906 --- /dev/null +++ b/libjava/javax/swing/SpinnerListModel.java @@ -0,0 +1,296 @@ +/* SpinnerListModel.java -- A spinner model backed by a list or an array. + 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; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * An implementation of <code>SpinnerModel</code> which uses the values + * contained within a list or an array. The backing list or array is + * only stored as a reference within the class. As a result, changes + * made elsewhere to the members of the list or array are reflected by + * this model. + * <p> + * + * The model itself inherits a list of <code>ChangeListener</code>s from + * <code>AbstractSpinnerModel</code>. As this code is unaware of changes + * made to the backing list or array, it is the responsibility of the + * application using the model to invoke <code>fireStateChanged()</code>, + * in order to notify any <code>ChangeListener</code>s, when the list or array + * changes. The model handles notification when the reference itself + * is changed via <code>setList()</code> or when the current value is + * set directly using <code>setValue()</code>. + * + * @author Andrew John Hughes <gnu_andrew@member.fsf.org> + * @see SpinnerModel + * @see AbstractSpinnerModel + * @see JSpinner + * @since 1.4 + */ + +public class SpinnerListModel + extends AbstractSpinnerModel + implements Serializable +{ + /** + * For compatability with Sun's JDK + */ + private static final long serialVersionUID = 3358804052191994516L; + + /** + * The backing list for this model. + */ + private List list; + + /** + * The current index in the list. + */ + private transient int index; + + /** + * Constructs a default <code>SpinnerListModel</code>. This + * is a model backed by a list containing only the single + * <code>String</code> element, "empty". + */ + public SpinnerListModel() + { + List defaultList; + + /* Create an empty list */ + defaultList = new ArrayList(); + /* Add the string "empty" */ + defaultList.add("empty"); + /* Set the list */ + setList(defaultList); + } + + /** + * Constructs a <code>SpinnerListModel</code> using the supplied list. + * The model maintains a reference to this list, and returns + * consecutive elements in response to calls to <code>getNextValue()</code>. + * The initial value is that at position 0, so an initial call + * to <code>getValue()</code> returns the same as <code>list.get(0)</code>. + * + * @param list The list to use for this model. + * @throws IllegalArgumentException if the list is null or contains no + * elements. + * @see SpinnerListModel#getNextValue() + * @see SpinnerListModel#getValue() + */ + public SpinnerListModel(List list) + { + /* Retain a reference to the valid list */ + setList(list); + } + + /** + * Constructs a <code>SpinnerListModel</code> using the supplied array. + * The model stores a reference to the wrapper list returned by + * <code>Arrays.asList()</code>. The wrapper list reflects modifications + * in the underlying array, so these changes will also be reflected + * by the model. The model produces consecutive elements from the array + * in response to calls to <code>getNextValue()</code>. The initial + * value returned by <code>getValue()</code> is the same as + * <code>array[0]</code>. + * + * @param array The array to use for this model. + * @throws IllegalArgumentException if the array is null or contains + * no elements. + * @see Arrays#asList(Object[]) + * @see SpinnerListModel#getNextValue() + * @see SpinnerListModel#getValue() + */ + public SpinnerListModel(Object[] array) + { + /* Check for a null or zero-sized array */ + if (array == null || array.length == 0) + { + throw new IllegalArgumentException("The supplied array was invalid."); + } + /* + Retain a reference to a wrapper around the valid array + The array, in list form, will be tested again here, but we can't really + avoid this -- a null value to Arrays.asList will throw a NullPointerException + */ + setList(Arrays.asList(array)); + } + + /** + * Returns the backing list for this model. + * + * @return The backing list. + */ + public List getList() + { + return list; + } + + /** + * Returns the next value from the list, which is the same as the element + * stored at the current index + 1. Null is returned if there are no more + * values to be returned (the end of the list has been reached). An + * ambiguity can occur here, as null may also be returned as a valid list + * element. This operation does not change the current value. + * + * @return The next value from the list or null. + */ + public Object getNextValue() + { + /* Check for a next value */ + if (index < (list.size() - 1)) + { + /* Return the element at the next index */ + return list.get(index + 1); + } + else + { + /* Return null as this is the end of the list */ + return null; + } + } + + /** + * Returns the previous value from the list, which is the same as the element + * stored at the current index - 1. Null is returned if there are no more + * values to be returned (the start of the list has been reached). An + * ambiguity can occur here, as null may also be returned as a valid list + * element. This operation does not change the current value. + * + * @return The previous value from the list or null. + */ + public Object getPreviousValue() + { + /* Check for a previous value. */ + if (index > 0) + { + /* Return the element at the previous position */ + return list.get(index - 1); + } + else + { + /* Return null as this is the start of the list */ + return null; + } + } + + /** + * Returns the current value of the model. Initially, this will + * be the element at position 0. On later invocations, this will + * be the last element returned by <code>getNextValue()</code> + * or <code>getPreviousValue()</code>. + * + * @return The current value. + * @see SpinnerListModel#getPreviousValue() + * @see SpinnerListModel#getNextValue() + */ + public Object getValue() + { + return list.get(index); + } + + /** + * Changes the backing list for this model. The model only stores + * a reference to the list, so any changes made to the list elsewhere + * will be reflected in the values returned by the model. A + * <code>ChangeEvent</code> is fired if the list being used actually + * changes (i.e. the new list is not referentially equal (!=) to the + * old one). + * + * @param list The new list to use. + * @throws IllegalArgumentException if the list is null or contains + * no elements. + * @see ChangeEvent + */ + public void setList(List list) + { + /* Check for null or zero size list */ + if (list == null || list.size() == 0) + { + throw new IllegalArgumentException("The supplied list was invalid."); + } + /* Check for a change of referenced list */ + if (this.list != list) + { + /* Store the new list */ + this.list = list; + /* Notify listeners of a change */ + fireStateChanged(); + } + /* We reset the other values in either case */ + /* Set the index to 0 */ + index = 0; + } + + /** + * Sets the current value of the model to be the one supplied. + * The value must exist within the backing list in order for + * the change to take place. Otherwise, an exception is thrown. + * The value used is the first occurrence of the value within + * the backing list. Listeners are notified of this change. + * Following the change, <code>getNextValue()</code> and + * <code>getPreviousValue()</code> return the objects following + * and prior to the supplied value, respectively. + * + * @param value The requested new value of the list. + * @throws IllegalArgumentException if the supplied value does + * not exist in the backing list. + * @see SpinnerListModel#getPreviousValue() + * @see SpinnerListModel#getNextValue() + */ + public void setValue(Object value) + { + int valueIndex; + + /* Search for the value in the list */ + valueIndex = list.indexOf(value); + /* Check for the value being found */ + if (valueIndex == -1) + { + throw new IllegalArgumentException("The supplied value does not " + + "exist in this list"); + } + /* Make the indices match */ + index = valueIndex; + /* Notify the listeners */ + fireStateChanged(); + } + +} diff --git a/libjava/javax/swing/SpinnerModel.java b/libjava/javax/swing/SpinnerModel.java index 5f8929ece83..ea5f431d462 100644 --- a/libjava/javax/swing/SpinnerModel.java +++ b/libjava/javax/swing/SpinnerModel.java @@ -1,5 +1,5 @@ /* SpinnerModel.java -- - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,10 +45,65 @@ import javax.swing.event.ChangeListener; */ public interface SpinnerModel { - void setValue (Object value); - public Object getValue (); - public Object getNextValue (); - public Object getPreviousValue (); - void addChangeListener (ChangeListener listener); - void removeChangeListener (ChangeListener listener); + /** + * Sets the current value of the model to that specified. + * Implementations can choose to refuse to accept the value + * and throw an exception instead. For example, a date model + * may throw invalid dates, or a list model may throw out + * values which don't exist in the underlying list. Models + * may also throw out unusual values, such as null. The decision + * is left to the discretion of the implementator. If the + * operation succeeds, the implementation should also notify + * any registered <code>ChangeListener</code>s. + * + * @param value The new value of the model. + * @throws IllegalArgumentException if the model does not accept + * the given value. + */ + void setValue(Object value); + + /** + * Returns the current value of the model. + * + * @return The current value. + */ + Object getValue(); + + /** + * Returns the next value from the model. If the model is bounded, + * this method may return null when the upper bound is met. + * The current value is not changed. + * + * @return The next value, or null if there are no more values + * to retrieve. + */ + Object getNextValue(); + + /** + * Returns the previous value from the model. If the model is + * bounded, this method may return null when the lower bound is + * met. The current value is not changed. + * + * @return The previous value, or null if there are no more + * values to retrieve. + */ + Object getPreviousValue(); + + /** + * Adds a <code>ChangeListener</code> to the list of registered + * listeners. Each listener is notified when the current value + * is changed. + * + * @param listener The new listener to register. + */ + void addChangeListener(ChangeListener listener); + + /** + * Removes a given <code>ChangeListener</code> from the list + * of registered listeners. + * + * @param listener The listener to remove. + */ + void removeChangeListener(ChangeListener listener); + } diff --git a/libjava/javax/swing/SpinnerNumberModel.java b/libjava/javax/swing/SpinnerNumberModel.java index 18588b51b76..370007cb895 100644 --- a/libjava/javax/swing/SpinnerNumberModel.java +++ b/libjava/javax/swing/SpinnerNumberModel.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing; +import java.io.Serializable; + /** * SpinnerNumberModel * @@ -44,7 +46,13 @@ package javax.swing; * @version 1.0 */ public class SpinnerNumberModel extends AbstractSpinnerModel + implements Serializable { + /** + * For compatability with Sun's JDK + */ + private static final long serialVersionUID = 7279176385485777821L; + /** DOCUMENT ME! */ private Number value; @@ -73,6 +81,8 @@ public class SpinnerNumberModel extends AbstractSpinnerModel * @param minimum the minimum value * @param maximum the maximum value * @param stepSize the step size + * @throws IllegalArgumentException if minimum <= value <= maximum does not + * hold */ public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) @@ -88,6 +98,8 @@ public class SpinnerNumberModel extends AbstractSpinnerModel * @param minimum the minimum value * @param maximum the maximum value * @param stepSize the step size + * @throws IllegalArgumentException if minimum <= value <= maximum does not + * hold */ public SpinnerNumberModel(int value, int minimum, int maximum, int stepSize) { @@ -238,4 +250,49 @@ public class SpinnerNumberModel extends AbstractSpinnerModel { return value; } + + public Comparable getMinimum() + { + return minimum; + } + + public void setMinimum(Comparable newMinimum) + { + if (minimum != newMinimum) + { + minimum = newMinimum; + fireStateChanged(); + } + } + + public Comparable getMaximum() + { + return maximum; + } + + public void setMaximum(Comparable newMaximum) + { + if (maximum != newMaximum) + { + maximum = newMaximum; + fireStateChanged(); + } + } + + public Number getStepSize() + { + return stepSize; + } + + public void setStepSize(Number newStepSize) + { + if (newStepSize == null) + throw new IllegalArgumentException(); + + if (stepSize != newStepSize) + { + stepSize = newStepSize; + fireStateChanged(); + } + } } diff --git a/libjava/javax/swing/SpringLayout.java b/libjava/javax/swing/SpringLayout.java index 60a50525f07..07357dcc862 100644 --- a/libjava/javax/swing/SpringLayout.java +++ b/libjava/javax/swing/SpringLayout.java @@ -42,12 +42,9 @@ import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.LayoutManager2; - import java.util.HashMap; import java.util.Map; -import javax.swing.Spring; - /** * A very flexible layout manager. Components are laid out by defining the * relationships between them. The relationships are expressed as @@ -91,7 +88,7 @@ public class SpringLayout implements LayoutManager2 * * @author Roman Kennke (roman@ontographics.com) */ - public final static class Constraints + public static class Constraints { // The constraints for each edge, and width and height. diff --git a/libjava/javax/swing/SwingUtilities.java b/libjava/javax/swing/SwingUtilities.java index 731a7bc8df7..feacf4fca22 100644 --- a/libjava/javax/swing/SwingUtilities.java +++ b/libjava/javax/swing/SwingUtilities.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; import java.applet.Applet; @@ -56,10 +57,10 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.lang.reflect.InvocationTargetException; + import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.InputMapUIResource; - /** * This class contains a number of static utility functions which are * useful when drawing swing components, dispatching events, or calculating @@ -75,6 +76,11 @@ public class SwingUtilities implements SwingConstants */ private static OwnerFrame ownerFrame; + private SwingUtilities() + { + // Do nothing. + } + /** * Calculates the portion of the base rectangle which is inside the * insets. @@ -1014,4 +1020,170 @@ public class SwingUtilities implements SwingConstants child.setParent(uiInputMap); } } + + /** + * Subtracts a rectangle from another and return the area as an array + * of rectangles. + * Returns the areas of rectA which are not covered by rectB. + * If the rectangles do not overlap, or if either parameter is + * <code>null</code>, a zero-size array is returned. + * @param rectA The first rectangle + * @param rectB The rectangle to subtract from the first + * @return An array of rectangles representing the area in rectA + * not overlapped by rectB + */ + public static Rectangle[] computeDifference(Rectangle rectA, Rectangle rectB) + { + if (rectA == null || rectB == null) + return new Rectangle[0]; + + Rectangle[] r = new Rectangle[4]; + int x1 = rectA.x; + int y1 = rectA.y; + int w1 = rectA.width; + int h1 = rectA.height; + int x2 = rectB.x; + int y2 = rectB.y; + int w2 = rectB.width; + int h2 = rectB.height; + + // (outer box = rectA) + // ------------- + // |_____0_____| + // | |rectB| | + // |_1|_____|_2| + // | 3 | + // ------------- + int H0 = (y2 > y1) ? y2 - y1 : 0; // height of box 0 + int H3 = (y2 + h2 < y1 + h1) ? y1 + h1 - y2 - h2 : 0; // height box 3 + int W1 = (x2 > x1) ? x2 - x1 : 0; // width box 1 + int W2 = (x1 + w1 > x2 + w2) ? x1 + w1 - x2 - w2 : 0; // w. box 2 + int H12 = (H0 + H3 < h1) ? h1 - H0 - H3 : 0; // height box 1 & 2 + + if (H0 > 0) + r[0] = new Rectangle(x1, y1, w1, H0); + else + r[0] = null; + + if (W1 > 0 && H12 > 0) + r[1] = new Rectangle(x1, y1 + H0, W1, H12); + else + r[1] = null; + + if (W2 > 0 && H12 > 0) + r[2] = new Rectangle(x2 + w2, y1 + H0, W2, H12); + else + r[2] = null; + + if (H3 > 0) + r[3] = new Rectangle(x1, y1 + H0 + H12, w1, H3); + else + r[3] = null; + + // sort out null objects + int n = 0; + for (int i = 0; i < 4; i++) + if (r[i] != null) + n++; + Rectangle[] out = new Rectangle[n]; + for (int i = 3; i >= 0; i--) + if (r[i] != null) + out[--n] = r[i]; + + return out; + } + + /** + * Calculates the intersection of two rectangles. + * + * @param x upper-left x coodinate of first rectangle + * @param x upper-left y coodinate of first rectangle + * @param w width of first rectangle + * @param h height of first rectangle + * @param rect a Rectangle object of the second rectangle + * @throws a NullPointerException if rect is null. + * + * @return a rectangle corresponding to the intersection of the + * two rectangles. A zero rectangle is returned if the rectangles + * do not overlap. + */ + public static Rectangle computeIntersection(int x, int y, int w, int h, + Rectangle rect) + { + int x2 = (int) rect.getX(); + int y2 = (int) rect.getY(); + int w2 = (int) rect.getWidth(); + int h2 = (int) rect.getHeight(); + + int dx = (x > x2) ? x : x2; + int dy = (y > y2) ? y : y2; + int dw = (x + w < x2 + w2) ? (x + w - dx) : (x2 + w2 - dx); + int dh = (y + h < y2 + h2) ? (y + h - dy) : (y2 + h2 - dy); + + if (dw >= 0 && dh >= 0) + return new Rectangle(dx, dy, dw, dh); + + return new Rectangle(0, 0, 0, 0); + } + + /** + * Calculates the width of a given string. + * + * @param fm the <code>FontMetrics</code> object to use + * @param str the string + * + * @return the width of the the string. + */ + public static int computeStringWidth(FontMetrics fm, String str) + { + return fm.stringWidth(str); + } + + /** + * Calculates the union of two rectangles. + * + * @param x upper-left x coodinate of first rectangle + * @param x upper-left y coodinate of first rectangle + * @param w width of first rectangle + * @param h height of first rectangle + * @param rect a Rectangle object of the second rectangle + * @throws a NullPointerException if rect is null. + * + * @return a rectangle corresponding to the union of the + * two rectangles. A rectangle encompassing both is returned if the + * rectangles do not overlap. + */ + public static Rectangle computeUnion(int x, int y, int w, int h, + Rectangle rect) + { + int x2 = (int) rect.getX(); + int y2 = (int) rect.getY(); + int w2 = (int) rect.getWidth(); + int h2 = (int) rect.getHeight(); + + int dx = (x < x2) ? x : x2; + int dy = (y < y2) ? y : y2; + int dw = (x + w > x2 + w2) ? (x + w - dx) : (x2 + w2 - dx); + int dh = (y + h > y2 + h2) ? (y + h - dy) : (y2 + h2 - dy); + + if (dw >= 0 && dh >= 0) + return new Rectangle(dx, dy, dw, dh); + + return new Rectangle(0, 0, 0, 0); + } + + /** + * Tests if a rectangle contains another. + * @param a first rectangle + * @param b second rectangle + * @return true if a contains b, false otherwise + * @throws NullPointerException + */ + public static boolean isRectangleContainingRectangle(Rectangle a, Rectangle b) + { + // Note: zero-size rects inclusive, differs from Rectangle.contains() + return b.width >= 0 && b.height >= 0 && b.width >= 0 && b.height >= 0 + && b.x >= a.x && b.x + b.width <= a.x + a.width && b.y >= a.y + && b.y + b.height <= a.y + a.height; + } } diff --git a/libjava/javax/swing/Timer.java b/libjava/javax/swing/Timer.java index 529ad19348c..afdf4f32d58 100644 --- a/libjava/javax/swing/Timer.java +++ b/libjava/javax/swing/Timer.java @@ -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; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.Serializable; import java.util.EventListener; -import javax.swing.event.EventListenerList; +import javax.swing.event.EventListenerList; /** * DOCUMENT ME! diff --git a/libjava/javax/swing/ToolTipManager.java b/libjava/javax/swing/ToolTipManager.java index 3556ef005a6..6245786afa3 100644 --- a/libjava/javax/swing/ToolTipManager.java +++ b/libjava/javax/swing/ToolTipManager.java @@ -37,28 +37,19 @@ exception statement from your version. */ package javax.swing; -import java.awt.AWTEvent; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Insets; import java.awt.LayoutManager; import java.awt.Panel; import java.awt.Point; import java.awt.Rectangle; -import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; -import javax.swing.JComponent; -import javax.swing.Popup; -import javax.swing.PopupFactory; -import javax.swing.SwingUtilities; -import javax.swing.Timer; - /** * This class is responsible for the registration of JToolTips to Components @@ -461,7 +452,13 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener { currentPoint = event.getPoint(); if (currentTip != null) - currentTip.setTipText(((JComponent) currentComponent).getToolTipText(event)); + { + if (currentComponent == null) + currentComponent = (Component) event.getSource(); + + String text = ((JComponent) currentComponent).getToolTipText(event); + currentTip.setTipText(text); + } if (enterTimer.isRunning()) enterTimer.restart(); } @@ -473,7 +470,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener */ private void showTip() { - if (! enabled) + if (! enabled || currentComponent == null) return; if (currentTip == null diff --git a/libjava/javax/swing/TransferHandler.java b/libjava/javax/swing/TransferHandler.java index e64df9c4cb3..16b5016b3af 100644 --- a/libjava/javax/swing/TransferHandler.java +++ b/libjava/javax/swing/TransferHandler.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing; import java.io.Serializable; +import java.awt.event.InputEvent; +import java.awt.datatransfer.*; public class TransferHandler implements Serializable { @@ -48,8 +50,66 @@ public class TransferHandler implements Serializable public static final int MOVE = 2; public static final int COPY_OR_MOVE = 3; + static Action getCopyAction () + { + return null; + } + + static Action getCutAction () + { + return null; + } + + static Action getPasteAction () + { + return null; + } + + protected TransferHandler() { // Do nothing here. } + + public TransferHandler(String property) + { + } + + public boolean canImport (JComponent c, DataFlavor[] flavors) + { + return false; + } + + public Transferable createTransferable(JComponent c) + { + return null; + } + + public void exportAsDrag (JComponent c, InputEvent e, int action) + { + } + + protected void exportDone (JComponent c, Transferable data, int action) + { + } + + public void exportToClipboard(JComponent c, Clipboard clip, int action) + { + } + + public int getSourceActions (JComponent c) + { + return 0; + } + + public Icon getVisualRepresentation (Transferable t) + { + return null; + } + + public boolean importData (JComponent c, Transferable t) + { + return false; + } + } diff --git a/libjava/javax/swing/UIDefaults.java b/libjava/javax/swing/UIDefaults.java index f72c2748cb0..c32cebd5a81 100644 --- a/libjava/javax/swing/UIDefaults.java +++ b/libjava/javax/swing/UIDefaults.java @@ -35,13 +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; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Insets; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.lang.reflect.Method; @@ -51,7 +51,6 @@ import java.util.ListIterator; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; -import java.util.Set; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; @@ -479,7 +478,7 @@ public class UIDefaults extends Hashtable propertyChangeSupport.addPropertyChangeListener(listener); } - void removePropertyChangeListener(PropertyChangeListener listener) + public void removePropertyChangeListener(PropertyChangeListener listener) { propertyChangeSupport.removePropertyChangeListener(listener); } diff --git a/libjava/javax/swing/UIManager.java b/libjava/javax/swing/UIManager.java index a600972aff3..9722129ab7c 100644 --- a/libjava/javax/swing/UIManager.java +++ b/libjava/javax/swing/UIManager.java @@ -44,6 +44,8 @@ import java.awt.Font; import java.awt.Insets; import java.beans.PropertyChangeListener; import java.io.Serializable; +import java.util.Locale; + import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.metal.MetalLookAndFeel; @@ -158,10 +160,43 @@ public class UIManager implements Serializable } public static LookAndFeel[] getAuxiliaryLookAndFeels() - { return aux_installed; } + { + return aux_installed; + } public static Object get(Object key) - { return getLookAndFeel().getDefaults().get(key); } + { + return getLookAndFeel().getDefaults().get(key); + } + + public static Object get(Object key, Locale locale) + { + return getLookAndFeel().getDefaults().get(key ,locale); + } + + /** + * Returns a boolean value from the defaults table, + * <code>false</code> if key is not present. + * + * @since 1.4 + */ + public static boolean getBoolean(Object key) + { + Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key); + return value != null ? value.booleanValue() : false; + } + + /** + * Returns a boolean value from the defaults table, + * <code>false</code> if key is not present. + * + * @since 1.4 + */ + public static boolean getBoolean(Object key, Locale locale) + { + Boolean value = (Boolean) getLookAndFeel().getDefaults().get(key, locale); + return value != null ? value.booleanValue() : false; + } /** * Returns a border from the defaults table. @@ -172,6 +207,16 @@ public class UIManager implements Serializable } /** + * Returns a border from the defaults table. + * + * @since 1.4 + */ + public static Border getBorder(Object key, Locale locale) + { + return (Border) getLookAndFeel().getDefaults().get(key, locale); + } + + /** * Returns a drawing color from the defaults table. */ public static Color getColor(Object key) @@ -180,6 +225,14 @@ public class UIManager implements Serializable } /** + * Returns a drawing color from the defaults table. + */ + public static Color getColor(Object key, Locale locale) + { + return (Color) getLookAndFeel().getDefaults().get(key); + } + + /** * this string can be passed to Class.forName() */ public static String getCrossPlatformLookAndFeelClassName() @@ -204,6 +257,14 @@ public class UIManager implements Serializable } /** + * Returns a dimension from the defaults table. + */ + public static Dimension getDimension(Object key, Locale locale) + { + return (Dimension) getLookAndFeel().getDefaults().get(key, locale); + } + + /** * Retrieves a font from the defaults table of the current * LookAndFeel. * @@ -217,6 +278,19 @@ public class UIManager implements Serializable } /** + * Retrieves a font from the defaults table of the current + * LookAndFeel. + * + * @param key an Object that specifies the font. Typically, + * this is a String such as + * <code>TitledBorder.font</code>. + */ + public static Font getFont(Object key, Locale locale) + { + return (Font) getLookAndFeel().getDefaults().get(key ,locale); + } + + /** * Returns an Icon from the defaults table. */ public static Icon getIcon(Object key) @@ -225,6 +299,14 @@ public class UIManager implements Serializable } /** + * Returns an Icon from the defaults table. + */ + public static Icon getIcon(Object key, Locale locale) + { + return (Icon) getLookAndFeel().getDefaults().get(key, locale); + } + + /** * Returns an Insets object from the defaults table. */ public static Insets getInsets(Object key) @@ -232,6 +314,14 @@ public class UIManager implements Serializable return (Insets) getLookAndFeel().getDefaults().getInsets(key); } + /** + * Returns an Insets object from the defaults table. + */ + public static Insets getInsets(Object key, Locale locale) + { + return (Insets) getLookAndFeel().getDefaults().getInsets(key, locale); + } + public static LookAndFeelInfo[] getInstalledLookAndFeels() { return installed; @@ -245,6 +335,14 @@ public class UIManager implements Serializable return x.intValue(); } + public static int getInt(Object key, Locale locale) + { + Integer x = (Integer) getLookAndFeel().getDefaults().get(key, locale); + if (x == null) + return 0; + return x.intValue(); + } + public static LookAndFeel getLookAndFeel() { return look_and_feel; @@ -268,6 +366,14 @@ public class UIManager implements Serializable } /** + * Returns a string from the defaults table. + */ + public static String getString(Object key, Locale locale) + { + return (String) getLookAndFeel().getDefaults().get(key, locale); + } + + /** * Returns the name of the LookAndFeel class that implements the * native systems look and feel if there is one, otherwise the name * of the default cross platform LookAndFeel class. diff --git a/libjava/javax/swing/border/MatteBorder.java b/libjava/javax/swing/border/MatteBorder.java index d5dc6ddf462..b95814b45c0 100644 --- a/libjava/javax/swing/border/MatteBorder.java +++ b/libjava/javax/swing/border/MatteBorder.java @@ -1,5 +1,5 @@ /* MatteBorder.java -- - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -42,8 +42,8 @@ import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Insets; -import javax.swing.Icon; +import javax.swing.Icon; /** * A border that is filled with either a solid color or with repeated diff --git a/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java b/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java index 37d6276988e..4ecfab4a3f3 100644 --- a/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java +++ b/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java @@ -1,5 +1,5 @@ /* AbstractColorChooserPanel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,15 +35,16 @@ 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.colorchooser; import java.awt.Color; import java.awt.Graphics; + import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JPanel; - /** * AbstractColorChooserPanel * diff --git a/libjava/javax/swing/colorchooser/ColorSelectionModel.java b/libjava/javax/swing/colorchooser/ColorSelectionModel.java index bd9abddfd86..2dc0e87c53c 100644 --- a/libjava/javax/swing/colorchooser/ColorSelectionModel.java +++ b/libjava/javax/swing/colorchooser/ColorSelectionModel.java @@ -1,5 +1,5 @@ /* ColorSelectionModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.colorchooser; import java.awt.Color; + import javax.swing.event.ChangeListener; /** diff --git a/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java b/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java index 90145edced8..8852935e563 100644 --- a/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java +++ b/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java @@ -1,5 +1,5 @@ /* DefaultColorSelectionModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,15 +35,16 @@ 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.colorchooser; import java.awt.Color; import java.io.Serializable; + import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; - /** * This is the default implementation of the ColorSelectionModel interface * that JColorChoosers use. diff --git a/libjava/javax/swing/colorchooser/DefaultHSBChooserPanel.java b/libjava/javax/swing/colorchooser/DefaultHSBChooserPanel.java index dcd795a7433..c2494039b8d 100644 --- a/libjava/javax/swing/colorchooser/DefaultHSBChooserPanel.java +++ b/libjava/javax/swing/colorchooser/DefaultHSBChooserPanel.java @@ -35,23 +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.colorchooser; 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.Image; -import java.awt.LayoutManager; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.image.MemoryImageSource; + import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.Icon; @@ -66,7 +65,6 @@ import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - /** * This is the Default HSB Panel displayed in the JColorChooser. */ @@ -377,7 +375,7 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel b))); spinnerTrigger = false; - if (! handlingMouse) + if (! handlingMouse && slider != null && ! slider.getValueIsAdjusting()) { updateImage(); updateTrack(); @@ -419,11 +417,6 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel internalChange = true; - // spinnerTrigger, internalChange, and handlingMouse are used because of the - // we don't want things like: change spinner -> update chooser -> change spinner - // That's because the value from before and after the update can differ - // slightly because of the conversion. - // FIXME: Think of better way to deal with this. if (! spinnerTrigger) { hSpinner.setValue(new Integer((int) (hsbVals[0] * 360))); @@ -438,8 +431,10 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel slider.setValue(((Number) hSpinner.getValue()).intValue()); if (! handlingMouse) { - gradientPoint.x = (int) ((1 - hsbVals[1]) * imgWidth); - gradientPoint.y = (int) ((1 - hsbVals[2]) * imgHeight); + gradientPoint.x = (int) ((1 + - ((Number) sSpinner.getValue()).intValue() / 100f) * imgWidth); + gradientPoint.y = (int) ((1 + - ((Number) bSpinner.getValue()).intValue() / 100f) * imgHeight); } break; case SLOCKED: @@ -447,8 +442,9 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel slider.setValue(((Number) sSpinner.getValue()).intValue()); if (! handlingMouse) { - gradientPoint.x = (int) (hsbVals[0] * imgWidth); - gradientPoint.y = (int) ((1 - hsbVals[2]) * imgHeight); + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / 360f * imgWidth); + gradientPoint.y = (int) ((1 + - ((Number) bSpinner.getValue()).intValue() / 100f) * imgHeight); } break; case BLOCKED: @@ -456,15 +452,19 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel slider.setValue(((Number) bSpinner.getValue()).intValue()); if (! handlingMouse) { - gradientPoint.x = (int) (hsbVals[0] * imgWidth); - gradientPoint.y = (int) ((1 - hsbVals[1]) * imgHeight); + gradientPoint.x = (int) (((Number) hSpinner.getValue()).intValue() / 360f * imgWidth); + gradientPoint.y = (int) ((1 + - ((Number) sSpinner.getValue()).intValue() / 100f) * imgHeight); } break; } internalChange = false; - updateImage(); - updateTrack(); + if (! handlingMouse && slider != null && ! slider.getValueIsAdjusting()) + updateImage(); + + if (! handlingMouse || locked != HLOCKED) + updateTrack(); updateTextFields(); } @@ -857,4 +857,16 @@ class DefaultHSBChooserPanel extends AbstractColorChooserPanel trackImage = createImage(new MemoryImageSource(trackWidth, imgHeight, trackPix, 0, trackWidth)); } + + /** + * This method returns the HSB values for the currently selected color. + * + * @return The HSB values for the currently selected color. + */ + private float[] getHSBValues() + { + Color c = getColorFromModel(); + float[] f = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); + return f; + } } diff --git a/libjava/javax/swing/colorchooser/DefaultPreviewPanel.java b/libjava/javax/swing/colorchooser/DefaultPreviewPanel.java index 93ecfc39a54..e1e7aa91f7f 100644 --- a/libjava/javax/swing/colorchooser/DefaultPreviewPanel.java +++ b/libjava/javax/swing/colorchooser/DefaultPreviewPanel.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.colorchooser; import java.awt.Color; @@ -43,12 +44,12 @@ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Insets; + import javax.swing.JColorChooser; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.Border; - /** * This is the default preview panel for the JColorChooser. The default * preview panel is responsible for displaying the currently selected color diff --git a/libjava/javax/swing/colorchooser/DefaultRGBChooserPanel.java b/libjava/javax/swing/colorchooser/DefaultRGBChooserPanel.java index f6c22e88577..6002854c01d 100644 --- a/libjava/javax/swing/colorchooser/DefaultRGBChooserPanel.java +++ b/libjava/javax/swing/colorchooser/DefaultRGBChooserPanel.java @@ -35,18 +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.colorchooser; -import java.awt.BorderLayout; import java.awt.Color; -import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; + import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; @@ -54,7 +53,6 @@ import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - /** * This is the default RGB panel for the JColorChooser. The color is selected * using three sliders that represent the RGB values. @@ -73,11 +71,14 @@ public class DefaultRGBChooserPanel extends AbstractColorChooserPanel */ public void stateChanged(ChangeEvent e) { - if (internalChange) + if (updateChange) return; + int color = R.getValue() << 16 | G.getValue() << 8 | B.getValue(); + sliderChange = true; getColorSelectionModel().setSelectedColor(new Color(color)); + sliderChange = false; } } @@ -93,23 +94,32 @@ public class DefaultRGBChooserPanel extends AbstractColorChooserPanel */ public void stateChanged(ChangeEvent e) { - if (internalChange) + if (updateChange) return; + int red = ((Number) RSpinner.getValue()).intValue(); int green = ((Number) GSpinner.getValue()).intValue(); int blue = ((Number) BSpinner.getValue()).intValue(); int color = red << 16 | green << 8 | blue; + spinnerChange = true; getColorSelectionModel().setSelectedColor(new Color(color)); + spinnerChange = false; } } + /** Whether the color change was initiated by the spinners. */ + private transient boolean spinnerChange = false; + + /** Whether the color change was initiated by the sliders. */ + private transient boolean sliderChange = false; + /** - * Whether the color change was initiated from the slider or spinner rather - * than externally. + * Whether the change was forced by the chooser (meaning the color has + * already been changed). */ - private transient boolean internalChange = false; + private transient boolean updateChange = false; /** The ChangeListener for the sliders. */ private transient ChangeListener colorChanger; @@ -175,22 +185,28 @@ public class DefaultRGBChooserPanel extends AbstractColorChooserPanel int green = rgb >> 8 & 0xff; int blue = rgb & 0xff; - internalChange = true; - - if (R != null) - R.setValue(red); - if (RSpinner != null) - RSpinner.setValue(new Integer(red)); - if (G != null) - G.setValue(green); - if (GSpinner != null) - GSpinner.setValue(new Integer(green)); - if (B != null) - B.setValue(blue); - if (BSpinner != null) - BSpinner.setValue(new Integer(blue)); - - internalChange = false; + updateChange = true; + + if (! sliderChange) + { + if (R != null) + R.setValue(red); + if (G != null) + G.setValue(green); + if (B != null) + B.setValue(blue); + } + if (! spinnerChange) + { + if (GSpinner != null) + GSpinner.setValue(new Integer(green)); + if (RSpinner != null) + RSpinner.setValue(new Integer(red)); + if (BSpinner != null) + BSpinner.setValue(new Integer(blue)); + } + + updateChange = false; revalidate(); repaint(); diff --git a/libjava/javax/swing/colorchooser/DefaultSwatchChooserPanel.java b/libjava/javax/swing/colorchooser/DefaultSwatchChooserPanel.java index 1413a5b2d5b..7e5a4eff0c5 100644 --- a/libjava/javax/swing/colorchooser/DefaultSwatchChooserPanel.java +++ b/libjava/javax/swing/colorchooser/DefaultSwatchChooserPanel.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.colorchooser; import java.awt.BorderLayout; @@ -48,12 +49,12 @@ import java.awt.LayoutManager; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; + import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JPanel; - /** * This class is the DefaultSwatchChooserPanel. This chooser panel displays a * set of colors that can be picked. Recently picked items will go into a diff --git a/libjava/javax/swing/event/AncestorEvent.java b/libjava/javax/swing/event/AncestorEvent.java index d62be28ba29..63f00a4e55b 100644 --- a/libjava/javax/swing/event/AncestorEvent.java +++ b/libjava/javax/swing/event/AncestorEvent.java @@ -1,5 +1,5 @@ /* AncestorEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing.event; import java.awt.AWTEvent; import java.awt.Container; + import javax.swing.JComponent; /** diff --git a/libjava/javax/swing/event/HyperlinkEvent.java b/libjava/javax/swing/event/HyperlinkEvent.java index c979fbf62da..a3a155a3174 100644 --- a/libjava/javax/swing/event/HyperlinkEvent.java +++ b/libjava/javax/swing/event/HyperlinkEvent.java @@ -1,5 +1,5 @@ /* HyperlinkEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing.event; import java.net.URL; import java.util.EventObject; + import javax.swing.text.Element; /** diff --git a/libjava/javax/swing/event/InternalFrameEvent.java b/libjava/javax/swing/event/InternalFrameEvent.java index 863fd292f88..9f03116773b 100644 --- a/libjava/javax/swing/event/InternalFrameEvent.java +++ b/libjava/javax/swing/event/InternalFrameEvent.java @@ -1,5 +1,5 @@ /* InternalFrameEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.event; import java.awt.AWTEvent; + import javax.swing.JInternalFrame; /** diff --git a/libjava/javax/swing/event/MenuDragMouseEvent.java b/libjava/javax/swing/event/MenuDragMouseEvent.java index b1eb841c4fe..8d3a0a5420f 100644 --- a/libjava/javax/swing/event/MenuDragMouseEvent.java +++ b/libjava/javax/swing/event/MenuDragMouseEvent.java @@ -1,5 +1,5 @@ /* MenuDragMouseEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,11 +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.event; -// Imports -import java.awt.event.MouseEvent; import java.awt.Component; +import java.awt.event.MouseEvent; + import javax.swing.MenuElement; import javax.swing.MenuSelectionManager; diff --git a/libjava/javax/swing/event/MenuKeyEvent.java b/libjava/javax/swing/event/MenuKeyEvent.java index 34653366fbc..aecc992688b 100644 --- a/libjava/javax/swing/event/MenuKeyEvent.java +++ b/libjava/javax/swing/event/MenuKeyEvent.java @@ -1,5 +1,5 @@ /* MenuKeyEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,11 +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.event; -// Imports import java.awt.Component; import java.awt.event.KeyEvent; + import javax.swing.MenuElement; import javax.swing.MenuSelectionManager; diff --git a/libjava/javax/swing/event/TableColumnModelEvent.java b/libjava/javax/swing/event/TableColumnModelEvent.java index 2525dfc8487..17a71e409b2 100644 --- a/libjava/javax/swing/event/TableColumnModelEvent.java +++ b/libjava/javax/swing/event/TableColumnModelEvent.java @@ -1,5 +1,5 @@ /* TableColumnModelEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,10 +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.event; -// Imports import java.util.EventObject; + import javax.swing.table.TableColumnModel; /** diff --git a/libjava/javax/swing/event/TableModelEvent.java b/libjava/javax/swing/event/TableModelEvent.java index 6bd96971950..ba8a36d3b8f 100644 --- a/libjava/javax/swing/event/TableModelEvent.java +++ b/libjava/javax/swing/event/TableModelEvent.java @@ -1,5 +1,5 @@ /* TableModelEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.event; import java.util.EventObject; + import javax.swing.table.TableModel; /** diff --git a/libjava/javax/swing/event/TreeExpansionEvent.java b/libjava/javax/swing/event/TreeExpansionEvent.java index ee8b7c017c6..40d08f02768 100644 --- a/libjava/javax/swing/event/TreeExpansionEvent.java +++ b/libjava/javax/swing/event/TreeExpansionEvent.java @@ -1,5 +1,5 @@ /* TreeExpansionEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,10 +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.event; -// Imports import java.util.EventObject; + import javax.swing.tree.TreePath; /** diff --git a/libjava/javax/swing/event/TreeModelEvent.java b/libjava/javax/swing/event/TreeModelEvent.java index 625dfe0c594..7dbbc7953ec 100644 --- a/libjava/javax/swing/event/TreeModelEvent.java +++ b/libjava/javax/swing/event/TreeModelEvent.java @@ -1,5 +1,5 @@ /* TreeModelEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,10 +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.event; -// Imports import java.util.EventObject; + import javax.swing.tree.TreePath; /** diff --git a/libjava/javax/swing/event/TreeSelectionEvent.java b/libjava/javax/swing/event/TreeSelectionEvent.java index 238d2fc5f0f..6d2f461e9c3 100644 --- a/libjava/javax/swing/event/TreeSelectionEvent.java +++ b/libjava/javax/swing/event/TreeSelectionEvent.java @@ -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.event; import java.util.EventObject; + import javax.swing.tree.TreePath; /** diff --git a/libjava/javax/swing/event/TreeWillExpandListener.java b/libjava/javax/swing/event/TreeWillExpandListener.java index b24c3710576..35364b9fb6d 100644 --- a/libjava/javax/swing/event/TreeWillExpandListener.java +++ b/libjava/javax/swing/event/TreeWillExpandListener.java @@ -1,5 +1,5 @@ /* TreeWillExpandListener.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.event; import java.util.EventListener; + import javax.swing.tree.ExpandVetoException; /** diff --git a/libjava/javax/swing/event/UndoableEditEvent.java b/libjava/javax/swing/event/UndoableEditEvent.java index be55e9b4555..9e989d1a4da 100644 --- a/libjava/javax/swing/event/UndoableEditEvent.java +++ b/libjava/javax/swing/event/UndoableEditEvent.java @@ -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.event; import java.util.EventObject; + import javax.swing.undo.UndoableEdit; /** diff --git a/libjava/javax/swing/filechooser/FileView.java b/libjava/javax/swing/filechooser/FileView.java index 7ff8ab0b9bb..f680e8fec70 100644 --- a/libjava/javax/swing/filechooser/FileView.java +++ b/libjava/javax/swing/filechooser/FileView.java @@ -1,5 +1,5 @@ /* FileView.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.filechooser; import java.io.File; + import javax.swing.Icon; /** 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"; } diff --git a/libjava/javax/swing/table/AbstractTableModel.java b/libjava/javax/swing/table/AbstractTableModel.java index dd8eb69382c..076487f5322 100644 --- a/libjava/javax/swing/table/AbstractTableModel.java +++ b/libjava/javax/swing/table/AbstractTableModel.java @@ -1,5 +1,5 @@ /* AbstractTableModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -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.table; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.EventListenerList; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; diff --git a/libjava/javax/swing/table/DefaultTableCellRenderer.java b/libjava/javax/swing/table/DefaultTableCellRenderer.java index ef829886147..ac5edb99586 100644 --- a/libjava/javax/swing/table/DefaultTableCellRenderer.java +++ b/libjava/javax/swing/table/DefaultTableCellRenderer.java @@ -1,4 +1,4 @@ -/* DefaultTableCellRenderer.java +/* DefaultTableCellRenderer.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,12 +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.table; import java.awt.Color; import java.awt.Component; import java.awt.Rectangle; import java.io.Serializable; + import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.border.Border; diff --git a/libjava/javax/swing/table/DefaultTableColumnModel.java b/libjava/javax/swing/table/DefaultTableColumnModel.java index d7a3c351938..b66b6951a99 100644 --- a/libjava/javax/swing/table/DefaultTableColumnModel.java +++ b/libjava/javax/swing/table/DefaultTableColumnModel.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.table; import java.beans.PropertyChangeEvent; @@ -43,8 +44,9 @@ import java.io.Serializable; import java.util.Enumeration; import java.util.EventListener; import java.util.Vector; -import javax.swing.ListSelectionModel; + import javax.swing.DefaultListSelectionModel; +import javax.swing.ListSelectionModel; import javax.swing.event.ChangeEvent; import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; @@ -52,7 +54,6 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.TableColumnModelEvent; import javax.swing.event.TableColumnModelListener; - /** * DefaultTableColumnModel * @author Andrew Selkirk @@ -288,26 +289,35 @@ public class DefaultTableColumnModel /** * addColumnModelListener - * @param value0 TODO + * @param listener the listener to add */ public void addColumnModelListener(TableColumnModelListener listener) { listenerList.add(TableColumnModelListener.class, listener); } - /** - * removeColumnModelListener - * @param value0 TODO - */ - public void removeColumnModelListener(TableColumnModelListener value0) + /** + * removeColumnModelListener + * @param listener the listener to remove + */ + public void removeColumnModelListener(TableColumnModelListener listener) { - // TODO + listenerList.remove(TableColumnModelListener.class, listener); } - /** - * fireColumnAdded - * @param value0 TODO - */ + /** + * @since 1.4 + */ + public TableColumnModelListener[] getColumnModelListeners() + { + return (TableColumnModelListener[]) + listenerList.getListeners(TableColumnModelListener.class); + } + + /** + * fireColumnAdded + * @param value0 TODO + */ protected void fireColumnAdded(TableColumnModelEvent value0) { // TODO diff --git a/libjava/javax/swing/table/DefaultTableModel.java b/libjava/javax/swing/table/DefaultTableModel.java index 8e111303c34..dd8e3b84612 100644 --- a/libjava/javax/swing/table/DefaultTableModel.java +++ b/libjava/javax/swing/table/DefaultTableModel.java @@ -1,5 +1,5 @@ /* DefaultTableModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing.table; import java.io.Serializable; import java.util.Vector; + import javax.swing.event.TableModelEvent; /** diff --git a/libjava/javax/swing/table/JTableHeader.java b/libjava/javax/swing/table/JTableHeader.java index 9e55647f42f..95ff92006cf 100644 --- a/libjava/javax/swing/table/JTableHeader.java +++ b/libjava/javax/swing/table/JTableHeader.java @@ -1,4 +1,4 @@ -/* JTableHeader.java +/* JTableHeader.java -- Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,8 +38,6 @@ exception statement from your version. */ package javax.swing.table; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; @@ -47,7 +45,7 @@ import java.awt.Font; import java.awt.FontMetrics; import java.awt.Point; import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; +import java.awt.event.FocusListener; import java.beans.PropertyChangeListener; import java.util.Locale; @@ -55,9 +53,9 @@ import javax.accessibility.Accessible; import javax.accessibility.AccessibleAction; import javax.accessibility.AccessibleComponent; import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleSelection; import javax.accessibility.AccessibleStateSet; -import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleText; import javax.accessibility.AccessibleValue; import javax.swing.JComponent; @@ -76,178 +74,222 @@ public class JTableHeader extends JComponent { throw new Error("not implemented"); } + public void addPropertyChangeListener(PropertyChangeListener l) { throw new Error("not implemented"); } + public boolean contains(Point p) { throw new Error("not implemented"); } + public AccessibleAction getAccessibleAction() { throw new Error("not implemented"); } + public Accessible getAccessibleAt(Point p) { throw new Error("not implemented"); } + public Accessible getAccessibleChild(int i) { throw new Error("not implemented"); } + public int getAccessibleChildrenCount() { throw new Error("not implemented"); } + public AccessibleComponent getAccessibleComponent() { throw new Error("not implemented"); } + public AccessibleContext getAccessibleContext() { throw new Error("not implemented"); } + public String getAccessibleDescription() { throw new Error("not implemented"); } + public int getAccessibleIndexInParent() { throw new Error("not implemented"); } + public String getAccessibleName() { throw new Error("not implemented"); } + public AccessibleRole getAccessibleRole() { throw new Error("not implemented"); } + public AccessibleSelection getAccessibleSelection() { throw new Error("not implemented"); } + public AccessibleStateSet getAccessibleStateSet() { throw new Error("not implemented"); } + public AccessibleText getAccessibleText() { throw new Error("not implemented"); } + public AccessibleValue getAccessibleValue() { throw new Error("not implemented"); } + public Color getBackground() { throw new Error("not implemented"); } + public Rectangle getBounds() { throw new Error("not implemented"); } + public Cursor getCursor() { throw new Error("not implemented"); } + public Font getFont() { throw new Error("not implemented"); } + public FontMetrics getFontMetrics(Font f) { throw new Error("not implemented"); } + public Color getForeground() { throw new Error("not implemented"); } + public Locale getLocale() { throw new Error("not implemented"); } + public Point getLocation() { throw new Error("not implemented"); } + public Point getLocationOnScreen() { throw new Error("not implemented"); } + public Dimension getSize() { throw new Error("not implemented"); } + public boolean isEnabled() { throw new Error("not implemented"); } + public boolean isFocusTraversable() { throw new Error("not implemented"); } + public boolean isShowing() { throw new Error("not implemented"); } + public boolean isVisible() { throw new Error("not implemented"); } + public void removeFocusListener(FocusListener l) { throw new Error("not implemented"); } + public void removePropertyChangeListener(PropertyChangeListener l) { throw new Error("not implemented"); } + public void requestFocus() { throw new Error("not implemented"); } + public void setAccessibleDescription(String s) { throw new Error("not implemented"); } + public void setAccessibleName(String s) { throw new Error("not implemented"); } + public void setBackground(Color c) { throw new Error("not implemented"); } + public void setBounds(Rectangle r) { throw new Error("not implemented"); } + public void setCursor(Cursor c) { throw new Error("not implemented"); } + public void setEnabled(boolean b) { throw new Error("not implemented"); } + public void setFont(Font f) { throw new Error("not implemented"); } + public void setForeground(Color c) { throw new Error("not implemented"); } + public void setLocation(Point p) { throw new Error("not implemented"); } + public void setSize(Dimension d) { throw new Error("not implemented"); } + public void setVisible(boolean b) { throw new Error("not implemented"); @@ -265,17 +307,17 @@ public class JTableHeader extends JComponent /** * The columnModel property. */ - TableColumnModel columnModel; + protected TableColumnModel columnModel; /** * The draggedColumn property. */ - TableColumn draggedColumn; + protected TableColumn draggedColumn; /** * The draggedDistance property. */ - int draggedDistance; + protected int draggedDistance; /** * The opaque property. @@ -285,27 +327,27 @@ public class JTableHeader extends JComponent /** * The reorderingAllowed property. */ - boolean reorderingAllowed; + protected boolean reorderingAllowed; /** * The resizingAllowed property. */ - boolean resizingAllowed; + protected boolean resizingAllowed = true; /** * The resizingColumn property. */ - TableColumn resizingColumn; + protected TableColumn resizingColumn; /** * The table property. */ - JTable table; + protected JTable table; /** * The updateTableInRealTime property. */ - boolean updateTableInRealTime; + protected boolean updateTableInRealTime; TableCellRenderer cellRenderer; @@ -317,7 +359,7 @@ public class JTableHeader extends JComponent public JTableHeader(TableColumnModel cm) { accessibleContext = new AccessibleJTableHeader(); - columnModel = cm == null ? createDefaultTableColumnModel() : cm; + columnModel = cm == null ? createDefaultColumnModel() : cm; draggedColumn = null; draggedDistance = 0; opaque = true; @@ -330,12 +372,11 @@ public class JTableHeader extends JComponent updateUI(); } - protected TableColumnModel createDefaultTableColumnModel() + protected TableColumnModel createDefaultColumnModel() { return new DefaultTableColumnModel(); } - /** * Get the value of the {@link #accessibleContext} property. * @@ -536,6 +577,11 @@ public class JTableHeader extends JComponent return cellRenderer; } + public void setDefaultRenderer(TableCellRenderer cellRenderer) + { + this.cellRenderer = cellRenderer; + } + public Rectangle getHeaderRect(int column) { Rectangle r = getTable().getCellRect(-1, column, true); diff --git a/libjava/javax/swing/table/TableCellEditor.java b/libjava/javax/swing/table/TableCellEditor.java index bb7904e3d40..d83812c1ac1 100644 --- a/libjava/javax/swing/table/TableCellEditor.java +++ b/libjava/javax/swing/table/TableCellEditor.java @@ -1,5 +1,5 @@ /* TableCellEditor.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -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.table; -// Imports import java.awt.Component; -import javax.swing.JTable; + import javax.swing.CellEditor; +import javax.swing.JTable; /** * TableCellEditor public interface diff --git a/libjava/javax/swing/table/TableCellRenderer.java b/libjava/javax/swing/table/TableCellRenderer.java index 6ad91c7e9b8..580226b3f02 100644 --- a/libjava/javax/swing/table/TableCellRenderer.java +++ b/libjava/javax/swing/table/TableCellRenderer.java @@ -1,5 +1,5 @@ /* TableCellRenderer.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,10 +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.table; -// Imports import java.awt.Component; + import javax.swing.JTable; /** diff --git a/libjava/javax/swing/table/TableColumn.java b/libjava/javax/swing/table/TableColumn.java index 02ef7f8009e..0aaad8b3f95 100644 --- a/libjava/javax/swing/table/TableColumn.java +++ b/libjava/javax/swing/table/TableColumn.java @@ -1,5 +1,5 @@ /* TableColumn.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -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.table; import java.beans.PropertyChangeListener; import java.io.Serializable; -import javax.swing.event.SwingPropertyChangeSupport; +import javax.swing.event.SwingPropertyChangeSupport; /** * TableColumn @@ -52,89 +53,91 @@ public class TableColumn { static final long serialVersionUID = -6113660025878112608L; - /** - * COLUMN_WIDTH_PROPERTY - */ - public static final String COLUMN_WIDTH_PROPERTY = "columWidth"; + /** + * COLUMN_WIDTH_PROPERTY + */ + public static final String COLUMN_WIDTH_PROPERTY = "columWidth"; - /** - * HEADER_VALUE_PROPERTY - */ - public static final String HEADER_VALUE_PROPERTY = "headerValue"; + /** + * HEADER_VALUE_PROPERTY + */ + public static final String HEADER_VALUE_PROPERTY = "headerValue"; - /** - * HEADER_RENDERER_PROPERTY - */ - public static final String HEADER_RENDERER_PROPERTY = "headerRenderer"; + /** + * HEADER_RENDERER_PROPERTY + */ + public static final String HEADER_RENDERER_PROPERTY = "headerRenderer"; - /** - * CELL_RENDERER_PROPERTY - */ - public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; + /** + * CELL_RENDERER_PROPERTY + */ + public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; - /** - * modelIndex - */ - protected int modelIndex; + /** + * modelIndex + */ + protected int modelIndex; - /** - * identifier - */ - protected Object identifier; + /** + * identifier + */ + protected Object identifier; - /** - * width - */ - protected int width; + /** + * width + */ + protected int width; - /** - * minWidth - */ - protected int minWidth = 15; + /** + * minWidth + */ + protected int minWidth = 15; - /** - * preferredWidth - */ - private int preferredWidth; + /** + * preferredWidth + */ + private int preferredWidth; - /** - * maxWidth - */ - protected int maxWidth = Integer.MAX_VALUE; + /** + * maxWidth + */ + protected int maxWidth = Integer.MAX_VALUE; - /** - * headerRenderer - */ - protected TableCellRenderer headerRenderer; + /** + * headerRenderer + */ + protected TableCellRenderer headerRenderer; - /** - * headerValue - */ - protected Object headerValue; + /** + * headerValue + */ + protected Object headerValue; - /** - * cellRenderer - */ - protected TableCellRenderer cellRenderer; + /** + * cellRenderer + */ + protected TableCellRenderer cellRenderer; - /** - * cellEditor - */ - protected TableCellEditor cellEditor; + /** + * cellEditor + */ + protected TableCellEditor cellEditor; - /** - * isResizable - */ - protected boolean isResizable = true; + /** + * isResizable + */ + protected boolean isResizable = true; - /** - * resizedPostingDisableCount - */ - protected transient int resizedPostingDisableCount; + /** + * resizedPostingDisableCount + * + * @deprecated 1.3 + */ + protected transient int resizedPostingDisableCount; - /** - * changeSupport - */ + /** + * changeSupport + */ private SwingPropertyChangeSupport changeSupport = new SwingPropertyChangeSupport(this); @@ -215,14 +218,15 @@ public class TableColumn */ private void firePropertyChange(String property, boolean oldValue, boolean newValue) - { - firePropertyChange(property, new Boolean(oldValue), new Boolean(newValue)); - } + { + firePropertyChange(property, Boolean.valueOf(oldValue), + Boolean.valueOf(newValue)); + } - /** - * setModelIndex - * @param modelIndex TODO - */ + /** + * setModelIndex + * @param modelIndex TODO + */ public void setModelIndex(int modelIndex) { this.modelIndex = modelIndex; @@ -470,17 +474,21 @@ public class TableColumn // TODO } - /** - * disableResizedPosting - */ + /** + * disableResizedPosting + * + * @deprecated 1.3 + */ public void disableResizedPosting() { // Does nothing } - /** - * enableResizedPosting - */ + /** + * enableResizedPosting + * + * @deprecated 1.3 + */ public void enableResizedPosting() { // Does nothing @@ -504,8 +512,16 @@ public class TableColumn changeSupport.removePropertyChangeListener(listener); } - /** - * createDefaultHeaderRenderer + /** + * @since 1.4 + */ + public PropertyChangeListener[] getPropertyChangeListeners() + { + return changeSupport.getPropertyChangeListeners(); + } + + /** + * createDefaultHeaderRenderer * @return TableCellRenderer */ protected TableCellRenderer createDefaultHeaderRenderer() diff --git a/libjava/javax/swing/table/TableColumnModel.java b/libjava/javax/swing/table/TableColumnModel.java index ef0897d165b..b825ca0606c 100644 --- a/libjava/javax/swing/table/TableColumnModel.java +++ b/libjava/javax/swing/table/TableColumnModel.java @@ -1,5 +1,5 @@ /* TableColumnModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,13 +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.table; import java.util.Enumeration; + import javax.swing.ListSelectionModel; import javax.swing.event.TableColumnModelListener; - /** * TableColumnModel public interface * @author Andrew Selkirk diff --git a/libjava/javax/swing/text/AbstractDocument.java b/libjava/javax/swing/text/AbstractDocument.java index a7c8c907e60..f579fbb213b 100644 --- a/libjava/javax/swing/text/AbstractDocument.java +++ b/libjava/javax/swing/text/AbstractDocument.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.text; import java.io.Serializable; @@ -43,6 +44,7 @@ import java.util.Dictionary; import java.util.Enumeration; import java.util.EventListener; import java.util.Vector; + import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.EventListenerList; @@ -53,7 +55,6 @@ import javax.swing.undo.AbstractUndoableEdit; import javax.swing.undo.CompoundEdit; import javax.swing.undo.UndoableEdit; - public abstract class AbstractDocument implements Document, Serializable { diff --git a/libjava/javax/swing/text/AttributeSet.java b/libjava/javax/swing/text/AttributeSet.java index 3f38a4cd249..68d36bcf49f 100644 --- a/libjava/javax/swing/text/AttributeSet.java +++ b/libjava/javax/swing/text/AttributeSet.java @@ -57,8 +57,8 @@ public interface AttributeSet { } - static Object NameAttribute = StyleConstants.NameAttribute; - static Object ResolveAttribute = StyleConstants.ResolveAttribute; + Object NameAttribute = StyleConstants.NameAttribute; + Object ResolveAttribute = StyleConstants.ResolveAttribute; boolean containsAttribute(Object name, Object value); boolean containsAttributes(AttributeSet attributes); diff --git a/libjava/javax/swing/text/Caret.java b/libjava/javax/swing/text/Caret.java index 7393a753e2c..62263a62ac3 100644 --- a/libjava/javax/swing/text/Caret.java +++ b/libjava/javax/swing/text/Caret.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.text; import java.awt.Graphics; import java.awt.Point; + import javax.swing.event.ChangeListener; public interface Caret diff --git a/libjava/javax/swing/text/DefaultCaret.java b/libjava/javax/swing/text/DefaultCaret.java index 516f0726ba0..15a76699601 100644 --- a/libjava/javax/swing/text/DefaultCaret.java +++ b/libjava/javax/swing/text/DefaultCaret.java @@ -37,7 +37,6 @@ exception statement from your version. */ package javax.swing.text; -import java.awt.Color; import java.awt.Graphics; import java.awt.Point; import java.awt.Rectangle; diff --git a/libjava/javax/swing/text/DefaultEditorKit.java b/libjava/javax/swing/text/DefaultEditorKit.java index 03d4ef3040e..0e3be209688 100644 --- a/libjava/javax/swing/text/DefaultEditorKit.java +++ b/libjava/javax/swing/text/DefaultEditorKit.java @@ -35,19 +35,20 @@ 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.text; import java.awt.Toolkit; import java.awt.event.ActionEvent; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; + import javax.swing.Action; import javax.swing.JEditorPane; - public class DefaultEditorKit extends EditorKit { public static class BeepAction diff --git a/libjava/javax/swing/text/DefaultHighlighter.java b/libjava/javax/swing/text/DefaultHighlighter.java index 234fcad60ff..8d0491b6612 100644 --- a/libjava/javax/swing/text/DefaultHighlighter.java +++ b/libjava/javax/swing/text/DefaultHighlighter.java @@ -44,10 +44,6 @@ import java.awt.Rectangle; import java.awt.Shape; import java.util.Vector; -import javax.swing.text.JTextComponent; -import javax.swing.text.View; - - public class DefaultHighlighter extends LayeredHighlighter { public static class DefaultHighlightPainter @@ -168,11 +164,22 @@ public class DefaultHighlighter extends LayeredHighlighter private JTextComponent textComponent; private Vector highlights = new Vector(); + private boolean drawsLayeredHighlights = true; public DefaultHighlighter() { } + public boolean getDrawsLayeredHighlights() + { + return drawsLayeredHighlights; + } + + public void setDrawsLayeredHighlights(boolean newValue) + { + drawsLayeredHighlights = newValue; + } + private void checkPositions(int p0, int p1) throws BadLocationException { diff --git a/libjava/javax/swing/text/Document.java b/libjava/javax/swing/text/Document.java index d197924bdf9..d3bbabb5369 100644 --- a/libjava/javax/swing/text/Document.java +++ b/libjava/javax/swing/text/Document.java @@ -44,7 +44,7 @@ import javax.swing.event.UndoableEditListener; public interface Document { String StreamDescriptionProperty = "stream"; - String TitleProperty = "text"; + String TitleProperty = "title"; void addDocumentListener(DocumentListener listener); diff --git a/libjava/javax/swing/text/DocumentFilter.java b/libjava/javax/swing/text/DocumentFilter.java index 7a8e95df98d..ff96d07299b 100644 --- a/libjava/javax/swing/text/DocumentFilter.java +++ b/libjava/javax/swing/text/DocumentFilter.java @@ -1,5 +1,5 @@ /* DocumentFilter.java -- - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,4 +40,44 @@ package javax.swing.text; public class DocumentFilter { + public abstract static class FilterBypass + { + public FilterBypass() + { + // Do nothing here. + } + + public abstract Document getDocument(); + + public abstract void insertString(int offset, String string, + AttributeSet attr) + throws BadLocationException; + + public abstract void remove(int offset, int length) + throws BadLocationException; + + public abstract void replace(int offset, int length, String string, + AttributeSet attrs) + throws BadLocationException; + } + + public void insertString(DocumentFilter.FilterBypass fb, int offset, + String string, AttributeSet attr) + throws BadLocationException + { + fb.insertString(offset, string, attr); + } + + public void remove(DocumentFilter.FilterBypass fb, int offset, int length) + throws BadLocationException + { + fb.remove(offset, length); + } + + public void replace(DocumentFilter.FilterBypass fb, int offset, int length, + String text, AttributeSet attr) + throws BadLocationException + { + fb.replace(offset, length, text, attr); + } } diff --git a/libjava/javax/swing/text/EditorKit.java b/libjava/javax/swing/text/EditorKit.java index 0609332f0b8..efca9657e26 100644 --- a/libjava/javax/swing/text/EditorKit.java +++ b/libjava/javax/swing/text/EditorKit.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.text; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import javax.swing.Action; import javax.swing.JEditorPane; - public abstract class EditorKit implements Cloneable, Serializable { diff --git a/libjava/javax/swing/text/FieldView.java b/libjava/javax/swing/text/FieldView.java index 06514b73f14..3f1de377230 100644 --- a/libjava/javax/swing/text/FieldView.java +++ b/libjava/javax/swing/text/FieldView.java @@ -43,7 +43,6 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Shape; - public class FieldView extends PlainView { public FieldView(Element elem) @@ -79,7 +78,6 @@ public class FieldView extends PlainView { // This should never happen. text = ""; - System.out.println("Michael: FieldView.getPreferredSpan: Error"); } return fm.stringWidth(text); diff --git a/libjava/javax/swing/text/GapContent.java b/libjava/javax/swing/text/GapContent.java index 93446826868..5826128724f 100644 --- a/libjava/javax/swing/text/GapContent.java +++ b/libjava/javax/swing/text/GapContent.java @@ -93,7 +93,7 @@ public class GapContent public String getString(int where, int len) throws BadLocationException { - return buf.toString(); + return buf.substring(where, where+len); } public void getChars(int where, int len, Segment txt) diff --git a/libjava/javax/swing/text/Highlighter.java b/libjava/javax/swing/text/Highlighter.java index 77471d17768..affec9b7a99 100644 --- a/libjava/javax/swing/text/Highlighter.java +++ b/libjava/javax/swing/text/Highlighter.java @@ -55,8 +55,7 @@ public interface Highlighter public interface HighlightPainter { - public void paint(Graphics g, int p0, int p1, Shape bounds, - JTextComponent c); + void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c); } void install(JTextComponent c); diff --git a/libjava/javax/swing/text/JTextComponent.java b/libjava/javax/swing/text/JTextComponent.java index ea69f5d16d9..0bca84b0fcf 100644 --- a/libjava/javax/swing/text/JTextComponent.java +++ b/libjava/javax/swing/text/JTextComponent.java @@ -35,19 +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.text; import java.awt.AWTEvent; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; -import java.awt.Image; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.InputMethodListener; import java.awt.event.KeyEvent; - import java.util.Enumeration; import java.util.Hashtable; @@ -58,7 +56,6 @@ import javax.accessibility.AccessibleStateSet; import javax.accessibility.AccessibleText; import javax.swing.Action; import javax.swing.ActionMap; -import javax.swing.Icon; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JViewport; @@ -73,7 +70,6 @@ import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.InputMapUIResource; import javax.swing.plaf.TextUI; - public abstract class JTextComponent extends JComponent implements Scrollable, Accessible { @@ -629,7 +625,7 @@ public abstract class JTextComponent extends JComponent * @see #setKeymap() * @see #keymap */ - Keymap getKeymap() + public Keymap getKeymap() { return keymap; } @@ -800,6 +796,7 @@ public abstract class JTextComponent extends JComponent private Color selectionColor; private boolean editable; private Insets margin; + private boolean dragEnabled; /** * Creates a new <code>JTextComponent</code> instance. @@ -921,6 +918,26 @@ public abstract class JTextComponent extends JComponent } /** + * Retrieves the currently selected text in this text document. + * + * @return the selected text + * + * @exception NullPointerException if the underlaying document is null + */ + public String getSelectedText() + { + try + { + return doc.getText(getSelectionStart(), getSelectionEnd()); + } + catch (BadLocationException e) + { + // This should never happen. + return null; + } + } + + /** * Returns a string that specifies the name of the Look and Feel class * that renders this component. * @@ -998,12 +1015,16 @@ public abstract class JTextComponent extends JComponent /** * Enables/disabled this text component's editability. * - * @param editable true to make it editable, false otherwise. + * @param newValue true to make it editable, false otherwise. */ - public void setEditable(boolean editable) + public void setEditable(boolean newValue) { - firePropertyChange("editable", this.editable, editable); - this.editable = editable; + if (editable == newValue) + return; + + boolean oldValue = editable; + editable = newValue; + firePropertyChange("editable", oldValue, newValue); } /** @@ -1225,17 +1246,22 @@ public abstract class JTextComponent extends JComponent try { + int start = getSelectionStart(); + int end = getSelectionEnd(); + // Remove selected text. if (dot != mark) - doc.remove(Math.min(dot, mark), Math.max(dot, mark)); + doc.remove(start, end - start); // Insert new text. - doc.insertString(Math.min(dot, mark), content, null); + doc.insertString(start, content, null); + + // Set dot to new position. + setCaretPosition(start + content.length()); } catch (BadLocationException e) { // This should never happen. - System.out.println("Michael: JTextComponent.replaceSelection: Error"); } } @@ -1333,4 +1359,14 @@ public abstract class JTextComponent extends JComponent { return getUI().modelToView(this, position); } + + public boolean getDragEnabled() + { + return dragEnabled; + } + + public void setDragEnabled(boolean enabled) + { + dragEnabled = enabled; + } } diff --git a/libjava/javax/swing/text/LayeredHighlighter.java b/libjava/javax/swing/text/LayeredHighlighter.java index 45932217a02..0b063e5a1df 100644 --- a/libjava/javax/swing/text/LayeredHighlighter.java +++ b/libjava/javax/swing/text/LayeredHighlighter.java @@ -40,10 +40,6 @@ package javax.swing.text; import java.awt.Graphics; import java.awt.Shape; -import javax.swing.text.JTextComponent; -import javax.swing.text.View; - - public abstract class LayeredHighlighter implements Highlighter { diff --git a/libjava/javax/swing/text/NavigationFilter.java b/libjava/javax/swing/text/NavigationFilter.java index 37d1c380a65..cdf9e77b7eb 100644 --- a/libjava/javax/swing/text/NavigationFilter.java +++ b/libjava/javax/swing/text/NavigationFilter.java @@ -1,5 +1,5 @@ /* NavigationFilter.java -- - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,4 +40,32 @@ package javax.swing.text; public class NavigationFilter { + public abstract static class FilterBypass + { + public FilterBypass() + { + // Do nothing here. + } + + public abstract Caret getCaret(); + public abstract void moveDot(int dot, Position.Bias bias); + public abstract void setDot(int dot, Position.Bias bias); + } + + public NavigationFilter() + { + // Do nothing here. + } + + public void moveDot(NavigationFilter.FilterBypass fb, int dot, + Position.Bias bias) + { + fb.moveDot(dot, bias); + } + + public void setDot(NavigationFilter.FilterBypass fb, int dot, + Position.Bias bias) + { + fb.setDot(dot, bias); + } } diff --git a/libjava/javax/swing/text/PasswordView.java b/libjava/javax/swing/text/PasswordView.java new file mode 100644 index 00000000000..f9db0417057 --- /dev/null +++ b/libjava/javax/swing/text/PasswordView.java @@ -0,0 +1,138 @@ +/* PasswordView.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.text; + +import java.awt.Color; +import java.awt.Graphics; + +import javax.swing.JPasswordField; + +public class PasswordView extends FieldView +{ + /** + * Buffer for putting the echo char into it and + * then using it to draw it into the view. + */ + private char[] oneCharBuffer = new char[1]; + + public PasswordView(Element elem) + { + super(elem); + } + + protected int drawEchoCharacter(Graphics g, int x, int y, char ch) + { + // Update font metrics. + updateMetrics(); + + // Draw character. + oneCharBuffer[0] = ch; + g.drawChars(oneCharBuffer, 0, 1, x, y); + + // Return new x position right of drawn character. + return x + metrics.charWidth(ch); + } + + private char getEchoChar() + { + char ch = ((JPasswordField) getContainer()).getEchoChar(); + + if (ch == 0) + ch = '*'; + + return ch; + } + + protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) + throws BadLocationException + { + // FIXME: Throw BadLocationException somehow. + + // Update font metrics. + updateMetrics(); + + // Get echo character. + char ch = getEchoChar(); + + // Set color for selected text. + g.setColor(selectedColor); + g.setColor(Color.BLACK); + + // Initialize buffer for faster drawing of all characters. + int len = p1 - p0; + char[] buffer = new char[len]; + for (int index = 0; index < len; ++index) + buffer[index] = ch; + + // Draw echo charaters. + g.drawChars(buffer, 0, len, x, y); + + // Return new x position right of all drawn characters. + return x + len * metrics.charWidth(ch); + } + + protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) + throws BadLocationException + { + // FIXME: Throw BadLocationException somehow. + + // Update font metrics. + updateMetrics(); + + // Get echo character. + char ch = getEchoChar(); + + // Set color for unselected text. + g.setColor(unselectedColor); + g.setColor(Color.BLACK); + + // Initialize buffer for faster drawing of all characters. + int len = p1 - p0; + char[] buffer = new char[len]; + for (int index = 0; index < len; ++index) + buffer[index] = ch; + + // Draw echo charaters. + g.drawChars(buffer, 0, len, x, y); + + // Return new x position right of all drawn characters. + return x + len * metrics.charWidth(ch); + } +} + diff --git a/libjava/javax/swing/text/PlainDocument.java b/libjava/javax/swing/text/PlainDocument.java index 4a8adfca54d..22808700a03 100644 --- a/libjava/javax/swing/text/PlainDocument.java +++ b/libjava/javax/swing/text/PlainDocument.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing.text; +import java.util.ArrayList; + public class PlainDocument extends AbstractDocument { private static final long serialVersionUID = 4758290289196893664L; @@ -59,14 +61,53 @@ public class PlainDocument extends AbstractDocument rootElement = createDefaultRoot(); } + protected void reindex() + { + Element[] lines; + try + { + String str = content.getString(0, content.length()); + + ArrayList elts = new ArrayList(); + int j = 0; + for (int i = str.indexOf('\n', 0); i != -1; i = str.indexOf('\n', i+1)) + { + elts.add(createLeafElement(rootElement, null, j, i)); + j = i; + } + + if (j < content.length()) + elts.add(createLeafElement(rootElement, null, j, content.length())); + + lines = new Element[elts.size()]; + for (int i = 0; i < elts.size(); ++i) + lines[i] = (Element) elts.get(i); + + } + catch (BadLocationException e) + { + lines = new Element[1]; + lines[0] = createLeafElement(rootElement, null, 0, 1); + } + + ((BranchElement) rootElement).replace(0, rootElement.getElementCount(), lines); + } + protected AbstractDocument.AbstractElement createDefaultRoot() { - BranchElement rootElement = - (BranchElement) createBranchElement(null, null); - Element[] lines = new Element[1]; - lines[0] = createLeafElement(rootElement, null, 0, 1); - rootElement.replace(0, 0, lines); - return rootElement; + rootElement = createBranchElement(null, null); + reindex(); + return (AbstractElement) rootElement; + } + + protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr) + { + reindex(); + } + + protected void removeUpdate(DefaultDocumentEvent chng) + { + reindex(); } public Element getDefaultRootElement() diff --git a/libjava/javax/swing/text/PlainView.java b/libjava/javax/swing/text/PlainView.java index 3dd8fe44842..bcec3538d64 100644 --- a/libjava/javax/swing/text/PlainView.java +++ b/libjava/javax/swing/text/PlainView.java @@ -50,9 +50,9 @@ import java.awt.Shape; public class PlainView extends View implements TabExpander { - private Color selectedColor; - private Color unselectedColor; - private Font font; + Color selectedColor; + Color unselectedColor; + Font font; protected FontMetrics metrics; @@ -130,7 +130,7 @@ public class PlainView extends View } } - public int drawSelectedText(Graphics g, int x, int y, int p0, int p1) + protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException { g.setColor(selectedColor); @@ -139,7 +139,7 @@ public class PlainView extends View return Utilities.drawTabbedText(segment, x, y, g, this, 0); } - public int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) + protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException { g.setColor(unselectedColor); diff --git a/libjava/javax/swing/text/SimpleAttributeSet.java b/libjava/javax/swing/text/SimpleAttributeSet.java index 746056dfe7a..1578a48ab27 100644 --- a/libjava/javax/swing/text/SimpleAttributeSet.java +++ b/libjava/javax/swing/text/SimpleAttributeSet.java @@ -35,19 +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.text; import java.io.Serializable; import java.util.Enumeration; import java.util.Hashtable; -import java.lang.Cloneable; public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cloneable { - Hashtable tab; + public static final AttributeSet EMPTY = new SimpleAttributeSet(); - static AttributeSet EMPTY = new SimpleAttributeSet(); + Hashtable tab; public SimpleAttributeSet() { @@ -57,7 +57,8 @@ public class SimpleAttributeSet public SimpleAttributeSet(AttributeSet a) { tab = new Hashtable(); - addAttributes(a); + if (a != null) + addAttributes(a); } public void addAttribute(Object name, Object value) diff --git a/libjava/javax/swing/text/StyleConstants.java b/libjava/javax/swing/text/StyleConstants.java index 2201c47b5b9..e1232af8725 100644 --- a/libjava/javax/swing/text/StyleConstants.java +++ b/libjava/javax/swing/text/StyleConstants.java @@ -35,16 +35,55 @@ 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.text; import java.awt.Color; import java.awt.Component; + import javax.swing.Icon; public class StyleConstants { + public static final int ALIGN_LEFT = 0; + public static final int ALIGN_CENTER = 1; + public static final int ALIGN_RIGHT = 2; + public static final int ALIGN_JUSTIFIED = 3; + + public static final Object Background = CharacterConstants.Background; + public static final Object BidiLevel = CharacterConstants.BidiLevel; + public static final Object Bold = CharacterConstants.Bold; + public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute; + public static final Object FontFamily = CharacterConstants.Family; + public static final Object FontSize = CharacterConstants.Size; + public static final Object Foreground = CharacterConstants.Foreground; + public static final Object IconAttribute = CharacterConstants.IconAttribute; + public static final Object Italic = CharacterConstants.Italic; + public static final Object StrikeThrough = CharacterConstants.StrikeThrough; + public static final Object Subscript = CharacterConstants.Subscript; + public static final Object Superscript = CharacterConstants.Superscript; + public static final Object Underline = CharacterConstants.Underline; + + public static final Object Alignment = ParagraphConstants.Alignment; + public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent; + public static final Object LeftIndent = ParagraphConstants.LeftIndent; + public static final Object LineSpacing = ParagraphConstants.LineSpacing; + public static final Object Orientation = ParagraphConstants.Orientation; + public static final Object RightIndent = ParagraphConstants.RightIndent; + public static final Object SpaceAbove = ParagraphConstants.SpaceAbove; + public static final Object SpaceBelow = ParagraphConstants.SpaceBelow; + public static final Object TabSet = ParagraphConstants.TabSet; + + public static final String ComponentElementName = "component"; + public static final String IconElementName = "icon"; + + public static final Object ComposedTextAttribute = new StyleConstants("composed text"); + public static final Object ModelAttribute = new StyleConstants("model"); + public static final Object NameAttribute = new StyleConstants("name"); + public static final Object ResolveAttribute = new StyleConstants("resolver"); String keyname; + private StyleConstants(String k) { keyname = k; @@ -55,43 +94,6 @@ public class StyleConstants return keyname; } - public static int ALIGN_CENTER; - public static int ALIGN_JUSTIFIED; - public static int ALIGN_LEFT; - public static int ALIGN_RIGHT; - - public static Object Background = CharacterConstants.Background; - public static Object BidiLevel = CharacterConstants.BidiLevel; - public static Object Bold = CharacterConstants.Bold; - public static Object ComponentAttribute = CharacterConstants.ComponentAttribute; - public static Object FontFamily = CharacterConstants.Family; - public static Object FontSize = CharacterConstants.Size; - public static Object Foreground = CharacterConstants.Foreground; - public static Object IconAttribute = CharacterConstants.IconAttribute; - public static Object Italic = CharacterConstants.Italic; - public static Object StrikeThrough = CharacterConstants.StrikeThrough; - public static Object Subscript = CharacterConstants.Subscript; - public static Object Superscript = CharacterConstants.Superscript; - public static Object Underline = CharacterConstants.Underline; - - public static Object Alignment = ParagraphConstants.Alignment; - public static Object FirstLineIndent = ParagraphConstants.FirstLineIndent; - public static Object LeftIndent = ParagraphConstants.LeftIndent; - public static Object LineSpacing = ParagraphConstants.LineSpacing; - public static Object Orientation = ParagraphConstants.Orientation; - public static Object RightIndent = ParagraphConstants.RightIndent; - public static Object SpaceAbove = ParagraphConstants.SpaceAbove; - public static Object SpaceBelow = ParagraphConstants.SpaceBelow; - public static Object TabSet = ParagraphConstants.TabSet; - - public static String ComponentElementName = new String("component"); - public static String IconElementName = new String("icon"); - - public static Object ComposedTextAttribute = new StyleConstants("composed text"); - public static Object ModelAttribute = new StyleConstants("model"); - public static Object NameAttribute = new StyleConstants("name"); - public static Object ResolveAttribute = new StyleConstants("resolver"); - public static int getAlignment(AttributeSet a) { if (a.isDefined(Alignment)) @@ -277,7 +279,7 @@ public class StyleConstants public static void setBold(MutableAttributeSet a, boolean b) { - a.addAttribute(Bold, new Boolean(b)); + a.addAttribute(Bold, Boolean.valueOf(b)); } public static void setComponent(MutableAttributeSet a, Component c) @@ -312,7 +314,7 @@ public class StyleConstants public static void setItalic(MutableAttributeSet a, boolean b) { - a.addAttribute(Italic, new Boolean(b)); + a.addAttribute(Italic, Boolean.valueOf(b)); } public static void setLeftIndent(MutableAttributeSet a, float i) @@ -342,17 +344,17 @@ public class StyleConstants public static void setStrikeThrough(MutableAttributeSet a, boolean b) { - a.addAttribute(StrikeThrough, new Boolean(b)); + a.addAttribute(StrikeThrough, Boolean.valueOf(b)); } public static void setSubscript(MutableAttributeSet a, boolean b) { - a.addAttribute(Subscript, new Boolean(b)); + a.addAttribute(Subscript, Boolean.valueOf(b)); } public static void setSuperscript(MutableAttributeSet a, boolean b) { - a.addAttribute(Superscript, new Boolean(b)); + a.addAttribute(Superscript, Boolean.valueOf(b)); } public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs) @@ -362,7 +364,7 @@ public class StyleConstants public static void setUnderline(MutableAttributeSet a, boolean b) { - a.addAttribute(Underline, new Boolean(b)); + a.addAttribute(Underline, Boolean.valueOf(b)); } // The remainder are so-called "typesafe enumerations" which diff --git a/libjava/javax/swing/text/StyleContext.java b/libjava/javax/swing/text/StyleContext.java index 8accd9b905b..beb809b89e4 100644 --- a/libjava/javax/swing/text/StyleContext.java +++ b/libjava/javax/swing/text/StyleContext.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.text; import java.awt.Color; @@ -45,13 +46,14 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import javax.swing.event.EventListenerList; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.util.Enumeration; import java.util.EventListener; import java.util.Hashtable; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; + public class StyleContext implements Serializable, AbstractDocument.AttributeContext { diff --git a/libjava/javax/swing/text/StyledEditorKit.java b/libjava/javax/swing/text/StyledEditorKit.java index d3db03e208d..f1858309a5a 100644 --- a/libjava/javax/swing/text/StyledEditorKit.java +++ b/libjava/javax/swing/text/StyledEditorKit.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.text; import java.awt.Color; @@ -42,12 +43,12 @@ import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; + import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; - /** * StyledEditorKit * diff --git a/libjava/javax/swing/text/TextAction.java b/libjava/javax/swing/text/TextAction.java index 029eed9c5e4..d07bcbf1f43 100644 --- a/libjava/javax/swing/text/TextAction.java +++ b/libjava/javax/swing/text/TextAction.java @@ -35,13 +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.text; import java.awt.event.ActionEvent; + import javax.swing.AbstractAction; import javax.swing.Action; - /** * TextAction * @author Andrew Selkirk diff --git a/libjava/javax/swing/text/Utilities.java b/libjava/javax/swing/text/Utilities.java index 61c13eef509..6d2b54680a0 100644 --- a/libjava/javax/swing/text/Utilities.java +++ b/libjava/javax/swing/text/Utilities.java @@ -91,13 +91,29 @@ public class Utilities FontMetrics metrics = g.getFontMetrics(); int ascent = metrics.getAscent(); + int pixelWidth = 0; + int pos = 0; + int len = 0; + for (int offset = s.offset; offset < (s.offset + s.count); ++offset) { - switch (buffer[offset]) + char c = buffer[offset]; + if (c == '\t' || c == '\n') + { + if (len > 0) { + g.drawChars(buffer, pos, len, pixelX, pixelY + ascent); + pixelX += pixelWidth; + pixelWidth = 0; + } + pos = offset+1; + len = 0; + } + + switch (c) { case '\t': // In case we have a tab, we just 'jump' over the tab. - // When we have no tab expander we just use the width of 'm'. + // When we have no tab expander we just use the width of ' '. if (e != null) pixelX = (int) e.nextTabStop((float) pixelX, startOffset + offset - s.offset); @@ -105,20 +121,20 @@ public class Utilities pixelX += metrics.charWidth(' '); break; case '\n': - // In case we have a newline, we must draw - // the buffer and jump on the next line. - g.drawChars(buffer, offset, 1, pixelX, y); + // In case we have a newline, we must jump to the next line. pixelY += metrics.getHeight(); pixelX = x; break; default: - // Here we draw the char. - g.drawChars(buffer, offset, 1, pixelX, pixelY + ascent); - pixelX += metrics.charWidth(buffer[offset]); + ++len; + pixelWidth += metrics.charWidth(buffer[offset]); break; } } + if (len > 0) + g.drawChars(buffer, pos, len, pixelX, pixelY + ascent); + return pixelX; } diff --git a/libjava/javax/swing/text/View.java b/libjava/javax/swing/text/View.java index 730753a342b..f9e44a90f54 100644 --- a/libjava/javax/swing/text/View.java +++ b/libjava/javax/swing/text/View.java @@ -40,7 +40,7 @@ package javax.swing.text; import java.awt.Container; import java.awt.Graphics; import java.awt.Shape; -import java.util.Vector; + import javax.swing.SwingConstants; public abstract class View implements SwingConstants diff --git a/libjava/javax/swing/text/html/HTML.java b/libjava/javax/swing/text/html/HTML.java index 7a24036317f..098a14715cb 100644 --- a/libjava/javax/swing/text/html/HTML.java +++ b/libjava/javax/swing/text/html/HTML.java @@ -59,6 +59,11 @@ public class HTML public static class UnknownTag extends Tag implements Serializable { + /** + * For compatability with Sun's JDK 1.4.2 rev. 5 + */ + private static final long serialVersionUID = -1534369342247250625L; + public UnknownTag(String id) { super(id); diff --git a/libjava/javax/swing/tree/AbstractLayoutCache.java b/libjava/javax/swing/tree/AbstractLayoutCache.java index 4362684fda3..6fb75f77f69 100644 --- a/libjava/javax/swing/tree/AbstractLayoutCache.java +++ b/libjava/javax/swing/tree/AbstractLayoutCache.java @@ -1,5 +1,5 @@ /* AbstractLayoutCache.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,58 +40,43 @@ package javax.swing.tree; import java.awt.Rectangle; import java.util.Enumeration; + import javax.swing.event.TreeModelEvent; /** - * AbstractLayoutCache + * class AbstractLayoutCache + * * @author Andrew Selkirk */ public abstract class AbstractLayoutCache implements RowMapper { - - //------------------------------------------------------------- - // Classes ---------------------------------------------------- - //------------------------------------------------------------- - /** - * NodeDimensions + * class NodeDimensions */ - public abstract static class NodeDimensions { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - + public abstract static class NodeDimensions + { /** - * Constructor NodeDimensions + * Creates <code>NodeDimensions</code> object. */ - public NodeDimensions() { - // TODO - } // NodeDimensions() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + public NodeDimensions() + { + // Do nothing here. + } /** * getNodeDimensions + * * @param value0 TODO * @param value1 TODO * @param value2 TODO * @param value3 TODO * @param value4 TODO - * @returns Rectangle + * @return Rectangle */ - public abstract Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4); - - - } // NodeDimensions - - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- + public abstract Rectangle getNodeDimensions(Object value0, int value1, + int value2, boolean value3, + Rectangle value4); + } /** * nodeDimensions @@ -118,201 +103,241 @@ public abstract class AbstractLayoutCache implements RowMapper */ protected int rowHeight; - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - /** * Constructor AbstractLayoutCache */ - public AbstractLayoutCache() { - // TODO - } // AbstractLayoutCache() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- + public AbstractLayoutCache() + { + // Do nothing here. + } /** * setNodeDimensions - * @param value0 TODO + * + * @param dimensions TODO */ - public void setNodeDimensions(NodeDimensions value0) { - // TODO - } // setNodeDimensions() + public void setNodeDimensions(NodeDimensions dimensions) + { + nodeDimensions = dimensions; + } /** * getNodeDimensions - * @returns NodeDimensions + * + * @return NodeDimensions */ - public NodeDimensions getNodeDimensions() { - return null; // TODO - } // getNodeDimensions() + public NodeDimensions getNodeDimensions() + { + return nodeDimensions; + } /** * getNodeDimensions + * * @param value0 TODO * @param value1 TODO * @param value2 TODO * @param value3 TODO * @param value4 TODO - * @returns Rectangle + * + * @return Rectangle */ - protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4) { + protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4) + { return null; // TODO - } // getNodeDimensions() + } /** - * setModel - * @param value0 TODO + * Sets the model that provides the tree data. + * + * @param the model */ - public void setModel(TreeModel value0) { - // TODO - } // setModel() + public void setModel(TreeModel model) + { + treeModel = model; + } /** - * getModel - * @returns TreeModel + * Returns the model that provides the tree data. + * + * @return the model */ - public TreeModel getModel() { - return null; // TODO - } // getModel() + public TreeModel getModel() + { + return treeModel; + } /** * setRootVisible - * @param value0 TODO + * + * @param visible <code>true</code> if root should be visible, + * <code>false</code> otherwise */ - public void setRootVisible(boolean value0) { - // TODO - } // setRootVisible() + public void setRootVisible(boolean visible) + { + rootVisible = visible; + } /** * isRootVisible - * @returns boolean + * + * @return <code>true</code> if root is visible, + * <code>false</code> otherwise */ - public boolean isRootVisible() { - return false; // TODO - } // isRootVisible() + public boolean isRootVisible() + { + return rootVisible; + } /** * setRowHeight - * @param value0 TODO + * + * @param height the row height */ - public void setRowHeight(int value0) { - // TODO - } // setRowHeight() + public void setRowHeight(int height) + { + rowHeight = height; + } /** * getRowHeight - * @returns int + * + * @return the row height */ - public int getRowHeight() { - return 0; // TODO - } // getRowHeight() + public int getRowHeight() + { + return rowHeight; + } /** * setSelectionModel - * @param value0 TODO + * + * @param model the model */ - public void setSelectionModel(TreeSelectionModel value0) { - // TODO - } // setSelectionModel() + public void setSelectionModel(TreeSelectionModel model) + { + treeSelectionModel = model; + } /** * getSelectionModel - * @returns TreeSelectionModel + * + * @return the model */ - public TreeSelectionModel getSelectionModel() { - return null; // TODO - } // getSelectionModel() + public TreeSelectionModel getSelectionModel() + { + return treeSelectionModel; + } /** * getPreferredHeight - * @returns int + * + * @return int */ - public int getPreferredHeight() { + public int getPreferredHeight() + { return 0; // TODO - } // getPreferredHeight() + } /** * getPreferredWidth + * * @param value0 TODO - * @returns int + * + * @return int */ - public int getPreferredWidth(Rectangle value0) { + public int getPreferredWidth(Rectangle value0) + { return 0; // TODO - } // getPreferredWidth() + } /** * isExpanded + * * @param value0 TODO - * @returns boolean + * + * @return boolean */ public abstract boolean isExpanded(TreePath value0); /** * getBounds + * * @param value0 TODO * @param value1 TODO - * @returns Rectangle + * + * @return Rectangle */ public abstract Rectangle getBounds(TreePath value0, Rectangle value1); /** * getPathForRow - * @param value0 TODO - * @returns TreePath + * + * @param row the row + * + * @return the tree path */ - public abstract TreePath getPathForRow(int value0); + public abstract TreePath getPathForRow(int row); /** * getRowForPath - * @param value0 TODO - * @returns int + * + * @param path the tree path + * + * @return the row */ - public abstract int getRowForPath(TreePath value0); + public abstract int getRowForPath(TreePath path); /** * getPathClosestTo + * * @param value0 TODO * @param value1 TODO - * @returns TreePath + * + * @return the tree path */ public abstract TreePath getPathClosestTo(int value0, int value1); /** * getVisiblePathsFrom - * @param value0 TODO - * @returns Enumeration + * + * @param path the tree path + * + * @return Enumeration */ - public abstract Enumeration getVisiblePathsFrom(TreePath value0); + public abstract Enumeration getVisiblePathsFrom(TreePath path); /** * getVisibleChildCount - * @param value0 TODO - * @returns int + * + * @param path the tree path + * + * @return int */ public abstract int getVisibleChildCount(TreePath value0); /** * setExpandedState + * * @param value0 TODO + * * @param value1 TODO */ public abstract void setExpandedState(TreePath value0, boolean value1); /** * getExpandedState - * @param value0 TODO - * @returns boolean + * + * @param path the tree path + * + * @return boolean */ - public abstract boolean getExpandedState(TreePath value0); + public abstract boolean getExpandedState(TreePath path); /** * getRowCount - * @returns int + * + * @return the number of rows */ public abstract int getRowCount(); @@ -323,50 +348,58 @@ public abstract class AbstractLayoutCache implements RowMapper /** * invalidatePathBounds - * @param value0 TODO + * + * @param path the tree path */ - public abstract void invalidatePathBounds(TreePath value0); + public abstract void invalidatePathBounds(TreePath path); /** * treeNodesChanged - * @param value0 TODO + * + * @param event the event to send */ - public abstract void treeNodesChanged(TreeModelEvent value0); + public abstract void treeNodesChanged(TreeModelEvent event); /** * treeNodesInserted - * @param value0 TODO + * + * @param event the event to send */ - public abstract void treeNodesInserted(TreeModelEvent value0); + public abstract void treeNodesInserted(TreeModelEvent event); /** * treeNodesRemoved - * @param value0 TODO + * + * @param event the event to send */ - public abstract void treeNodesRemoved(TreeModelEvent value0); + public abstract void treeNodesRemoved(TreeModelEvent event); /** * treeStructureChanged - * @param value0 TODO + * + * @param event the event to send */ - public abstract void treeStructureChanged(TreeModelEvent value0); + public abstract void treeStructureChanged(TreeModelEvent event); /** * getRowsForPaths - * @param value0 TODO - * @returns int[] + * + * @param paths the tree paths + * + * @return an array of rows */ - public int[] getRowsForPaths(TreePath[] value0) { + public int[] getRowsForPaths(TreePath[] paths) + { return null; // TODO - } // getRowsForPaths() + } /** * isFixedRowHeight - * @returns boolean + * + * @return boolean */ - protected boolean isFixedRowHeight() { + protected boolean isFixedRowHeight() + { return false; // TODO - } // isFixedRowHeight() - - -} // AbstractLayoutCache + } +} diff --git a/libjava/javax/swing/tree/DefaultTreeCellEditor.java b/libjava/javax/swing/tree/DefaultTreeCellEditor.java index bebdc6a9e64..af280201bc1 100644 --- a/libjava/javax/swing/tree/DefaultTreeCellEditor.java +++ b/libjava/javax/swing/tree/DefaultTreeCellEditor.java @@ -56,6 +56,7 @@ import javax.swing.JTextField; import javax.swing.JTree; import javax.swing.border.Border; import javax.swing.event.CellEditorListener; +import javax.swing.event.EventListenerList; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -63,440 +64,453 @@ import javax.swing.event.TreeSelectionListener; * DefaultTreeCellEditor * @author Andrew Selkirk */ -public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor, TreeSelectionListener { - - //------------------------------------------------------------- - // Classes ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * EditorContainer - */ - public class EditorContainer extends Container { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor EditorContainer - * @param value0 TODO - */ - public EditorContainer(DefaultTreeCellEditor value0) { - // TODO - } // EditorContainer() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getPreferredSize - * @returns Dimension - */ - public Dimension getPreferredSize() { - return null; // TODO - } // getPreferredSize() - - /** - * paint - * @param value0 TODO - */ - public void paint(Graphics value0) { - // TODO - } // paint() - - /** - * doLayout - */ - public void doLayout() { - // TODO - } // doLayout() - - - } // EditorContainer - - /** - * DefaultTextField - */ - public class DefaultTextField extends JTextField { - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * border - */ - protected Border border; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultTextField - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTextField(DefaultTreeCellEditor value0, Border value1) { - // TODO - } // DefaultTextField() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getFont - * @returns Font - */ - public Font getFont() { - return null; // TODO - } // getFont() - - /** - * getBorder - * @returns Border - */ - public Border getBorder() { - return null; // TODO - } // getBorder() - - /** - * getPreferredSize - * @returns Dimension - */ - public Dimension getPreferredSize() { - return null; // TODO - } // getPreferredSize() - - - } // DefaultTextField - - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * realEditor - */ - protected TreeCellEditor realEditor; - - /** - * renderer - */ - protected DefaultTreeCellRenderer renderer; - - /** - * editingContainer - */ - protected Container editingContainer; - - /** - * editingComponent - */ - protected transient Component editingComponent; - - /** - * canEdit - */ - protected boolean canEdit; - - /** - * offset - */ - protected transient int offset; - - /** - * tree - */ - protected transient JTree tree; - - /** - * lastPath - */ - protected transient TreePath lastPath; - - /** - * timer - */ - protected transient javax.swing.Timer timer; // TODO - - /** - * lastRow - */ - protected transient int lastRow; - - /** - * borderSelectionColor - */ - protected Color borderSelectionColor; - - /** - * editingIcon - */ - protected transient Icon editingIcon; - - /** - * font - */ - protected Font font; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultTreeCellEditor - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1) { - // TODO - } // DefaultTreeCellEditor() - - /** - * Constructor DefaultTreeCellEditor - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - */ - public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1, TreeCellEditor value2) { - // TODO - } // DefaultTreeCellEditor() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param value0 TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream value0) throws IOException { - // TODO - } // writeObject() - - /** - * readObject - * @param value0 TODO - * @exception IOException TODO - * @exception ClassNotFoundException TODO - */ - private void readObject(ObjectInputStream value0) throws IOException, ClassNotFoundException { - // TODO - } // readObject() - - /** - * setBorderSelectionColor - * @param value0 TODO - */ - public void setBorderSelectionColor(Color value0) { - // TODO - } // setBorderSelectionColor() - - /** - * getBorderSelectionColor - * @returns Color - */ - public Color getBorderSelectionColor() { - return null; // TODO - } // getBorderSelectionColor() - - /** - * setFont - * @param value0 TODO - */ - public void setFont(Font value0) { - // TODO - } // setFont() - - /** - * getFont - * @returns Font - */ - public Font getFont() { - return null; // TODO - } // getFont() - - /** - * getTreeCellEditorComponent - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - * @param value4 TODO - * @param value5 TODO - * @returns Component - */ - public Component getTreeCellEditorComponent(JTree value0, Object value1, boolean value2, boolean value3, boolean value4, int value5) { - return null; // TODO - } // getTreeCellEditorComponent() - - /** - * getCellEditorValue - * @returns Object - */ - public Object getCellEditorValue() { - return null; // TODO - } // getCellEditorValue() - - /** - * isCellEditable - * @param value0 TODO - * @returns boolean - */ - public boolean isCellEditable(EventObject value0) { - return false; // TODO - } // isCellEditable() - - /** - * shouldSelectCell - * @param value0 TODO - * @returns boolean - */ - public boolean shouldSelectCell(EventObject value0) { - return false; // TODO - } // shouldSelectCell() - - /** - * stopCellEditing - * @returns boolean - */ - public boolean stopCellEditing() { - return false; // TODO - } // stopCellEditing() - - /** - * cancelCellEditing - */ - public void cancelCellEditing() { - // TODO - } // cancelCellEditing() - - /** - * addCellEditorListener - * @param value0 TODO - */ - public void addCellEditorListener(CellEditorListener value0) { - // TODO - } // addCellEditorListener() - - /** - * removeCellEditorListener - * @param value0 TODO - */ - public void removeCellEditorListener(CellEditorListener value0) { - // TODO - } // removeCellEditorListener() - - /** - * valueChanged - * @param value0 TODO - */ - public void valueChanged(TreeSelectionEvent value0) { - // TODO - } // valueChanged() - - /** - * actionPerformed - * @param value0 TODO - */ - public void actionPerformed(ActionEvent value0) { - // TODO - } // actionPerformed() - - /** - * setTree - * @param value0 TODO - */ - protected void setTree(JTree value0) { - // TODO - } // setTree() - - /** - * shouldStartEditingTimer - * @param value0 TODO - * @returns boolean - */ - protected boolean shouldStartEditingTimer(EventObject value0) { - return false; // TODO - } // shouldStartEditingTimer() - - /** - * startEditingTimer - */ - protected void startEditingTimer() { - // TODO - } // startEditingTimer() - - /** - * canEditImmediately - * @param value0 TODO - * @returns boolean - */ - protected boolean canEditImmediately(EventObject value0) { - return false; // TODO - } // canEditImmediately() - - /** - * inHitRegion - * @param value0 TODO - * @param value1 TODO - * @returns boolean - */ - protected boolean inHitRegion(int value0, int value1) { - return false; // TODO - } // inHitRegion() - - /** - * determineOffset - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - * @param value4 TODO - * @param value5 TODO - */ - protected void determineOffset(JTree value0, Object value1, boolean value2, boolean value3, boolean value4, int value5) { - // TODO - } // determineOffset() - - /** - * prepareForEditing - */ - protected void prepareForEditing() { - // TODO - } // prepareForEditing() - - /** - * createContainer - * @returns Container - */ - protected Container createContainer() { - return null; // TODO - } // createContainer() - - /** - * createTreeCellEditor - * @returns TreeCellEditor - */ - protected TreeCellEditor createTreeCellEditor() { - return null; // TODO - } // createTreeCellEditor() - - -} // DefaultTreeCellEditor +public class DefaultTreeCellEditor + implements ActionListener, TreeCellEditor, TreeSelectionListener +{ + /** + * EditorContainer + */ + public class EditorContainer extends Container + { + /** + * Creates an <code>EditorContainer</code> object. + */ + public EditorContainer() + { + // Do nothing here. + } + + /** + * This method only exists for API compatibility and is useless as it does + * nothing. It got probably introduced by accident. + */ + public void EditorContainer() + { + // Do nothing here. + } + + /** + * getPreferredSize + * @return Dimension + */ + public Dimension getPreferredSize() + { + return null; // TODO + } + + /** + * paint + * @param value0 TODO + */ + public void paint(Graphics value0) + { + // TODO + } + + /** + * doLayout + */ + public void doLayout() + { + // TODO + } + } + + /** + * DefaultTextField + */ + public class DefaultTextField extends JTextField + { + /** + * border + */ + protected Border border; + + /** + * Creates a <code>DefaultTextField</code> object. + * + * @param border the border to use + */ + public DefaultTextField(Border border) + { + this.border = border; + } + + /** + * getFont + * @return Font + */ + public Font getFont() + { + return null; // TODO + } + + /** + * Returns the border of the text field. + * + * @return the border + */ + public Border getBorder() + { + return border; + } + + /** + * getPreferredSize + * @return Dimension + */ + public Dimension getPreferredSize() + { + return null; // TODO + } + } + + private EventListenerList listenerList = new EventListenerList(); + + /** + * realEditor + */ + protected TreeCellEditor realEditor; + + /** + * renderer + */ + protected DefaultTreeCellRenderer renderer; + + /** + * editingContainer + */ + protected Container editingContainer; + + /** + * editingComponent + */ + protected transient Component editingComponent; + + /** + * canEdit + */ + protected boolean canEdit; + + /** + * offset + */ + protected transient int offset; + + /** + * tree + */ + protected transient JTree tree; + + /** + * lastPath + */ + protected transient TreePath lastPath; + + /** + * timer + */ + protected transient javax.swing.Timer timer; // TODO + + /** + * lastRow + */ + protected transient int lastRow; + + /** + * borderSelectionColor + */ + protected Color borderSelectionColor; + + /** + * editingIcon + */ + protected transient Icon editingIcon; + + /** + * font + */ + protected Font font; + + /** + * Constructor DefaultTreeCellEditor + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1) + { + // TODO + } + + /** + * Constructor DefaultTreeCellEditor + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + */ + public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1, + TreeCellEditor value2) + { + // TODO + } + + /** + * writeObject + * @param value0 TODO + * @exception IOException TODO + */ + private void writeObject(ObjectOutputStream value0) throws IOException + { + // TODO + } + + /** + * readObject + * @param value0 TODO + * @exception IOException TODO + * @exception ClassNotFoundException TODO + */ + private void readObject(ObjectInputStream value0) + throws IOException, ClassNotFoundException + { + // TODO + } + + /** + * setBorderSelectionColor + * @param value0 TODO + */ + public void setBorderSelectionColor(Color value0) + { + // TODO + } + + /** + * getBorderSelectionColor + * @return Color + */ + public Color getBorderSelectionColor() + { + return null; // TODO + } + + /** + * setFont + * @param value0 TODO + */ + public void setFont(Font value0) + { + // TODO + } + + /** + * getFont + * @return Font + */ + public Font getFont() + { + return null; // TODO + } + + /** + * getTreeCellEditorComponent + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + * @param value3 TODO + * @param value4 TODO + * @param value5 TODO + * @return Component + */ + public Component getTreeCellEditorComponent(JTree value0, Object value1, + boolean value2, boolean value3, + boolean value4, int value5) + { + return null; // TODO + } + + /** + * getCellEditorValue + * @return Object + */ + public Object getCellEditorValue() + { + return null; // TODO + } + + /** + * isCellEditable + * @param value0 TODO + * @return boolean + */ + public boolean isCellEditable(EventObject value0) + { + return false; // TODO + } + + /** + * shouldSelectCell + * @param value0 TODO + * @return boolean + */ + public boolean shouldSelectCell(EventObject value0) + { + return false; // TODO + } + + /** + * stopCellEditing + * @return boolean + */ + public boolean stopCellEditing() + { + return false; // TODO + } + + /** + * cancelCellEditing + */ + public void cancelCellEditing() + { + // TODO + } + + /** + * Adds a <code>CellEditorListener</code> object to this editor. + * + * @param listener the listener to add + */ + public void addCellEditorListener(CellEditorListener listener) + { + listenerList.add(CellEditorListener.class, listener); + } + + /** + * Removes a <code>CellEditorListener</code> object. + * + * @param listener the listener to remove + */ + public void removeCellEditorListener(CellEditorListener listener) + { + listenerList.remove(CellEditorListener.class, listener); + } + + /** + * Returns all added <code>CellEditorListener</code> objects to this editor. + * + * @return an array of listeners + * + * @since 1.4 + */ + public CellEditorListener[] getCellEditorListeners() + { + return (CellEditorListener[]) listenerList.getListeners(CellEditorListener.class); + } + + /** + * valueChanged + * @param value0 TODO + */ + public void valueChanged(TreeSelectionEvent value0) + { + // TODO + } + + /** + * actionPerformed + * @param value0 TODO + */ + public void actionPerformed(ActionEvent value0) + { + // TODO + } + + /** + * setTree + * @param value0 TODO + */ + protected void setTree(JTree value0) + { + // TODO + } + + /** + * shouldStartEditingTimer + * @param value0 TODO + * @return boolean + */ + protected boolean shouldStartEditingTimer(EventObject value0) + { + return false; // TODO + } + + /** + * startEditingTimer + */ + protected void startEditingTimer() + { + // TODO + } + + /** + * canEditImmediately + * @param value0 TODO + * @return boolean + */ + protected boolean canEditImmediately(EventObject value0) + { + return false; // TODO + } + + /** + * inHitRegion + * @param value0 TODO + * @param value1 TODO + * @return boolean + */ + protected boolean inHitRegion(int value0, int value1) + { + return false; // TODO + } + + /** + * determineOffset + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + * @param value3 TODO + * @param value4 TODO + * @param value5 TODO + */ + protected void determineOffset(JTree value0, Object value1, boolean value2, + boolean value3, boolean value4, int value5) + { + // TODO + } + + /** + * prepareForEditing + */ + protected void prepareForEditing() + { + // TODO + } + + /** + * createContainer + * @return Container + */ + protected Container createContainer() + { + return null; // TODO + } + + /** + * createTreeCellEditor + * @return TreeCellEditor + */ + protected TreeCellEditor createTreeCellEditor() + { + return null; // TODO + } +} diff --git a/libjava/javax/swing/tree/DefaultTreeCellRenderer.java b/libjava/javax/swing/tree/DefaultTreeCellRenderer.java index f0eb454db5c..beae3840b40 100644 --- a/libjava/javax/swing/tree/DefaultTreeCellRenderer.java +++ b/libjava/javax/swing/tree/DefaultTreeCellRenderer.java @@ -1,5 +1,5 @@ /* DefaultTreeCellRenderer.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,9 +44,13 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Rectangle; + import javax.swing.Icon; import javax.swing.JLabel; import javax.swing.JTree; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.UIResource; /** * DefaultTreeCellRenderer @@ -124,8 +128,18 @@ public class DefaultTreeCellRenderer * Constructor DefaultTreeCellRenderer */ public DefaultTreeCellRenderer() { - // TODO - } // DefaultTreeCellRenderer() + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + + setLeafIcon(getDefaultLeafIcon()); + setOpenIcon(getDefaultOpenIcon()); + setClosedIcon(getDefaultClosedIcon()); + + setTextNonSelectionColor(defaults.getColor("Tree.textForeground")); + setTextSelectionColor(defaults.getColor("Tree.selectionForeground")); + setBackgroundNonSelectionColor(defaults.getColor("Tree.textBackground")); + setBackgroundSelectionColor(defaults.getColor("Tree.selectionBackground")); + setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor")); + } //------------------------------------------------------------- @@ -137,168 +151,172 @@ public class DefaultTreeCellRenderer * @returns Icon */ public Icon getDefaultOpenIcon() { - return null; // TODO - } // getDefaultOpenIcon() + return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon"); + } /** * getDefaultClosedIcon * @returns Icon */ public Icon getDefaultClosedIcon() { - return null; // TODO - } // getDefaultClosedIcon() + return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon"); + } /** * getDefaultLeafIcon * @returns Icon */ public Icon getDefaultLeafIcon() { - return null; // TODO - } // getDefaultLeafIcon() + return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon"); + } /** * setOpenIcon * @param value0 TODO */ - public void setOpenIcon(Icon value0) { - // TODO - } // setOpenIcon() + public void setOpenIcon(Icon i) { + openIcon = i; + } /** * getOpenIcon * @returns Icon */ public Icon getOpenIcon() { - return null; // TODO - } // getOpenIcon() + return openIcon; + } /** * setClosedIcon * @param value0 TODO */ - public void setClosedIcon(Icon value0) { - // TODO - } // setClosedIcon() + public void setClosedIcon(Icon i) { + closedIcon = i; + } /** * getClosedIcon * @returns Icon */ public Icon getClosedIcon() { - return null; // TODO - } // getClosedIcon() + return closedIcon; + } /** * setLeafIcon * @param value0 TODO */ - public void setLeafIcon(Icon value0) { - // TODO - } // setLeafIcon() + public void setLeafIcon(Icon i) { + leafIcon = i; + } /** * getLeafIcon * @returns Icon */ public Icon getLeafIcon() { - return null; // TODO - } // getLeafIcon() + return leafIcon; + } /** * setTextSelectionColor * @param value0 TODO */ - public void setTextSelectionColor(Color value0) { - // TODO - } // setTextSelectionColor() + public void setTextSelectionColor(Color c) { + textSelectionColor = c; + } /** * getTextSelectionColor * @returns Color */ public Color getTextSelectionColor() { - return null; // TODO - } // getTextSelectionColor() + return textSelectionColor; + } /** * setTextNonSelectionColor * @param value0 TODO */ - public void setTextNonSelectionColor(Color value0) { - // TODO - } // setTextNonSelectionColor() + public void setTextNonSelectionColor(Color c) { + textNonSelectionColor = c; + } /** * getTextNonSelectionColor * @returns Color */ public Color getTextNonSelectionColor() { - return null; // TODO - } // getTextNonSelectionColor() + return textNonSelectionColor; + } /** * setBackgroundSelectionColor * @param value0 TODO */ - public void setBackgroundSelectionColor(Color value0) { - // TODO - } // setBackgroundSelectionColor() + public void setBackgroundSelectionColor(Color c) { + backgroundSelectionColor = c; + } /** * getBackgroundSelectionColor * @returns Color */ public Color getBackgroundSelectionColor() { - return null; // TODO - } // getBackgroundSelectionColor() + return backgroundSelectionColor; + } /** * setBackgroundNonSelectionColor * @param value0 TODO */ - public void setBackgroundNonSelectionColor(Color value0) { - // TODO - } // setBackgroundNonSelectionColor() + public void setBackgroundNonSelectionColor(Color c) { + backgroundNonSelectionColor = c; + } /** * getBackgroundNonSelectionColor * @returns Color */ public Color getBackgroundNonSelectionColor() { - return null; // TODO - } // getBackgroundNonSelectionColor() + return backgroundNonSelectionColor; + } /** * setBorderSelectionColor * @param value0 TODO */ - public void setBorderSelectionColor(Color value0) { - // TODO - } // setBorderSelectionColor() + public void setBorderSelectionColor(Color c) { + borderSelectionColor = c; + } /** * getBorderSelectionColor * @returns Color */ public Color getBorderSelectionColor() { - return null; // TODO - } // getBorderSelectionColor() + return borderSelectionColor; + } /** * setFont * @param value0 TODO */ - public void setFont(Font value0) { - // TODO - } // setFont() + public void setFont(Font f) { + if (f != null && f instanceof UIResource) + f = null; + super.setFont(f); + } /** * setBackground * @param value0 TODO */ - public void setBackground(Color value0) { - // TODO - } // setBackground() + public void setBackground(Color c) { + if (c != null && c instanceof UIResource) + c = null; + super.setBackground(c); + } /** * getTreeCellRendererComponent @@ -311,17 +329,37 @@ public class DefaultTreeCellRenderer * @param value6 TODO * @returns Component */ - public Component getTreeCellRendererComponent(JTree value0, Object value1, boolean value2, boolean value3, boolean value4, int value5, boolean value6) { - return null; // TODO - } // getTreeCellRendererComponent() + public Component getTreeCellRendererComponent(JTree tree, + Object val, + boolean selected, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { + this.selected = selected; + this.hasFocus = hasFocus; + + if (leaf) + setIcon(getLeafIcon()); + else if (expanded) + setIcon(getOpenIcon()); + else + setIcon(getClosedIcon()); + + setText(val.toString()); + setHorizontalAlignment(LEFT); + setVerticalAlignment(TOP); + + return this; + } /** * paint * @param value0 TODO */ - public void paint(Graphics value0) { - // TODO - } // paint() + public void paint(Graphics g) { + super.paint(g); + } /** * getPreferredSize diff --git a/libjava/javax/swing/tree/DefaultTreeModel.java b/libjava/javax/swing/tree/DefaultTreeModel.java index 4f546acca3e..2e34a35223e 100644 --- a/libjava/javax/swing/tree/DefaultTreeModel.java +++ b/libjava/javax/swing/tree/DefaultTreeModel.java @@ -1,5 +1,5 @@ /* DefaultTreeModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,335 +43,409 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.EventListener; + import javax.swing.event.EventListenerList; +import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; /** * DefaultTreeModel * @author Andrew Selkirk */ -public class DefaultTreeModel implements Serializable, TreeModel +public class DefaultTreeModel + implements Serializable, TreeModel { static final long serialVersionUID = -2621068368932566998L; - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * root - */ - protected TreeNode root = null; - - /** - * listenerList - */ - protected EventListenerList listenerList = new EventListenerList(); - - /** - * asksAllowsChildren - */ - protected boolean asksAllowsChildren; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultTreeModel - * @param value0 TODO - */ - public DefaultTreeModel(TreeNode root) { - setRoot(root); - } // DefaultTreeModel() - - /** - * Constructor DefaultTreeModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren) { - setRoot(root); - this.asksAllowsChildren = asksAllowsChildren; - } // DefaultTreeModel() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param value0 TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream value0) throws IOException { - // TODO - } // writeObject() - - /** - * readObject - * @param value0 TODO - * @exception IOException TODO - * @exception ClassNotFoundException TODO - */ - private void readObject(ObjectInputStream value0) throws IOException, ClassNotFoundException { - // TODO - } // readObject() - - /** - * asksAllowsChildren - * @returns boolean - */ - public boolean asksAllowsChildren() { - return asksAllowsChildren; - } // asksAllowsChildren() - - /** - * setAsksAllowsChildren - * @param value0 TODO - */ - public void setAsksAllowsChildren(boolean value) { - asksAllowsChildren = value; // TODO - } // setAsksAllowsChildren() - - /** - * setRoot - * @param value0 TODO - */ - public void setRoot(TreeNode root) { - - // Sanity Check - if (root == null) { - throw new IllegalArgumentException("null root"); - } // if - - // Set new root - this.root = root; - - // TODO - } // setRoot() - - /** - * getRoot - * @returns Object - */ - public Object getRoot() { - return root; - } // getRoot() - - /** - * getIndexOfChild - * @param value0 TODO - * @param value1 TODO - * @returns int - */ - public int getIndexOfChild(Object parent, Object child) { - return 0; // TODO - } // getIndexOfChild() - - /** - * getChild - * @param value0 TODO - * @param value1 TODO - * @returns Object - */ - public Object getChild(Object value0, int value1) { - return null; // TODO - } // getChild() - - /** - * getChildCount - * @param value0 TODO - * @returns int - */ - public int getChildCount(Object value0) { - return 0; // TODO - } // getChildCount() - - /** - * isLeaf - * @param value0 TODO - * @returns boolean - */ - public boolean isLeaf(Object value0) { - return false; // TODO - } // isLeaf() - - /** - * reload - */ - public void reload() { - // TODO - } // reload() - - /** - * reload - * @param value0 TODO - */ - public void reload(TreeNode value0) { - // TODO - } // reload() - - /** - * valueForPathChanged - * @param value0 TODO - * @param value1 TODO - */ - public void valueForPathChanged(TreePath value0, Object value1) { - // TODO - } // valueForPathChanged() - - /** - * insertNodeInto - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - */ - public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1, int value2) { - // TODO - } // insertNodeInto() - - /** - * removeNodeFromParent - * @param value0 TODO - */ - public void removeNodeFromParent(MutableTreeNode value0) { - // TODO - } // removeNodeFromParent() - - /** - * nodeChanged - * @param value0 TODO - */ - public void nodeChanged(TreeNode value0) { - // TODO - } // nodeChanged() - - /** - * nodesWereInserted - * @param value0 TODO - * @param value1 TODO - */ - public void nodesWereInserted(TreeNode value0, int[] value1) { - // TODO - } // nodesWereInserted() - - /** - * nodesWereRemoved - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - */ - public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2) { - // TODO - } // nodesWereRemoved() - - /** - * nodesChanged - * @param value0 TODO - * @param value1 TODO - */ - public void nodesChanged(TreeNode value0, int[] value1) { - // TODO - } // nodesChanged() - - /** - * nodeStructureChanged - * @param value0 TODO - */ - public void nodeStructureChanged(TreeNode value0) { - // TODO - } // nodeStructureChanged() - - /** - * getPathToRoot - * @param value0 TODO - * @returns TreeNode[] - */ - public TreeNode[] getPathToRoot(TreeNode value0) { - return null; // TODO - } // getPathToRoot() - - /** - * getPathToRoot - * @param value0 TODO - * @param value1 TODO - * @returns TreeNode[] - */ - protected TreeNode[] getPathToRoot(TreeNode value0, int value1) { - return null; // TODO - } // getPathToRoot() - - /** - * addTreeModelListener - * @param value0 TODO - */ - public void addTreeModelListener(TreeModelListener listener) { - listenerList.add(TreeModelListener.class, listener); - } // addTreeModelListener() - - /** - * removeTreeModelListener - * @param value0 TODO - */ - public void removeTreeModelListener(TreeModelListener listener) { - listenerList.remove(TreeModelListener.class, listener); - } // removeTreeModelListener() - - /** - * fireTreeNodesChanged - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - */ - protected void fireTreeNodesChanged(Object value0, Object[] value1, int[] value2, Object[] value3) { - // TODO - } // fireTreeNodesChanged() - - /** - * fireTreeNodesInserted - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - */ - protected void fireTreeNodesInserted(Object value0, Object[] value1, int[] value2, Object[] value3) { - // TODO - } // fireTreeNodesInserted() - - /** - * fireTreeNodesRemoved - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - */ - protected void fireTreeNodesRemoved(Object value0, Object[] value1, int[] value2, Object[] value3) { - // TODO - } // fireTreeNodesRemoved() - - /** - * fireTreeStructureChanged - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - * @param value3 TODO - */ - protected void fireTreeStructureChanged(Object value0, Object[] value1, int[] value2, Object[] value3) { - // TODO - } // fireTreeStructureChanged() - - /** - * getListeners - * @param value0 TODO - * @returns EventListener[] - */ - public EventListener[] getListeners(Class classType) { - return listenerList.getListeners(classType); - } // getListeners() - - -} // DefaultTreeModel + /** + * root + */ + protected TreeNode root = null; + + /** + * listenerList + */ + protected EventListenerList listenerList = new EventListenerList(); + + /** + * asksAllowsChildren + */ + protected boolean asksAllowsChildren; + + /** + * Constructor DefaultTreeModel + * @param value0 TODO + */ + public DefaultTreeModel(TreeNode root) + { + setRoot(root); + } + + /** + * Constructor DefaultTreeModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren) + { + setRoot(root); + this.asksAllowsChildren = asksAllowsChildren; + } + + /** + * writeObject + * @param value0 TODO + * @exception IOException TODO + */ + private void writeObject(ObjectOutputStream value0) throws IOException + { + // TODO + } + + /** + * readObject + * @param value0 TODO + * @exception IOException TODO + * @exception ClassNotFoundException TODO + */ + private void readObject(ObjectInputStream value0) + throws IOException, ClassNotFoundException + { + // TODO + } + + /** + * asksAllowsChildren + * @return boolean + */ + public boolean asksAllowsChildren() + { + return asksAllowsChildren; + } + + /** + * setAsksAllowsChildren + * @param value0 TODO + */ + public void setAsksAllowsChildren(boolean value) + { + asksAllowsChildren = value; // TODO + } + + /** + * setRoot + * @param value0 TODO + */ + public void setRoot(TreeNode root) + { + // Sanity Check + if (root == null) + { + throw new IllegalArgumentException("null root"); + } + // Set new root + this.root = root; + + // TODO + } + + /** + * getRoot + * @return Object + */ + public Object getRoot() + { + return root; + } + + /** + * getIndexOfChild + * @param value0 TODO + * @param value1 TODO + * @return int + */ + public int getIndexOfChild(Object parent, Object child) + { + return 0; // TODO + } + + /** + * getChild + * @param value0 TODO + * @param value1 TODO + * @return Object + */ + public Object getChild(Object node, int idx) + { + if (node instanceof TreeNode) + return ((TreeNode)node).getChildAt(idx); + else + return null; + } + + /** + * getChildCount + * @param value0 TODO + * @return int + */ + public int getChildCount(Object node) + { + if (node instanceof TreeNode) + return ((TreeNode)node).getChildCount(); + else + return 0; + } + + /** + * isLeaf + * @param value0 TODO + * @return boolean + */ + public boolean isLeaf(Object node) + { + if (node instanceof TreeNode) + return ((TreeNode)node).isLeaf(); + else + return true; + } + + /** + * reload + */ + public void reload() + { + // TODO + } + + /** + * reload + * @param value0 TODO + */ + public void reload(TreeNode value0) + { + // TODO + } + + /** + * valueForPathChanged + * @param value0 TODO + * @param value1 TODO + */ + public void valueForPathChanged(TreePath value0, Object value1) + { + // TODO + } + + /** + * insertNodeInto + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + */ + public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1, + int value2) + { + // TODO + } + + /** + * removeNodeFromParent + * @param value0 TODO + */ + public void removeNodeFromParent(MutableTreeNode value0) + { + // TODO + } + + /** + * nodeChanged + * @param value0 TODO + */ + public void nodeChanged(TreeNode value0) + { + // TODO + } + + /** + * nodesWereInserted + * @param value0 TODO + * @param value1 TODO + */ + public void nodesWereInserted(TreeNode value0, int[] value1) + { + // TODO + } + + /** + * nodesWereRemoved + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + */ + public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2) + { + // TODO + } + + /** + * nodesChanged + * @param value0 TODO + * @param value1 TODO + */ + public void nodesChanged(TreeNode value0, int[] value1) + { + // TODO + } + + /** + * nodeStructureChanged + * @param value0 TODO + */ + public void nodeStructureChanged(TreeNode value0) + { + // TODO + } + + /** + * getPathToRoot + * @param value0 TODO + * @return TreeNode[] + */ + public TreeNode[] getPathToRoot(TreeNode value0) + { + return null; // TODO + } + + /** + * getPathToRoot + * @param value0 TODO + * @param value1 TODO + * @return TreeNode[] + */ + protected TreeNode[] getPathToRoot(TreeNode value0, int value1) + { + return null; // TODO + } + + /** + * Registers a listere to the model. + * + * @param listener the listener to add + */ + public void addTreeModelListener(TreeModelListener listener) + { + listenerList.add(TreeModelListener.class, listener); + } + + /** + * Removes a listener from the model. + * + * @param listener the listener to remove + */ + public void removeTreeModelListener(TreeModelListener listener) + { + listenerList.remove(TreeModelListener.class, listener); + } + + /** + * Returns all registered <code>TreeModelListener</code> listeners. + * + * @return an array of listeners. + * + * @since 1.4 + */ + public TreeModelListener[] getTreeModelListeners() + { + return (TreeModelListener[]) listenerList.getListeners(TreeModelListener.class); + } + + /** + * fireTreeNodesChanged + * + * @param source the node being changed + * @param path the path to the root node + * @param childIndices the indices of the changed elements + * @param children the changed elements + */ + protected void fireTreeNodesChanged(Object source, Object[] path, + int[] childIndices, Object[] children) + { + TreeModelEvent event = + new TreeModelEvent(source, path, childIndices, children); + TreeModelListener[] listeners = getTreeModelListeners(); + + for (int i = listeners.length - 1; i >= 0; --i) + listeners[i].treeNodesChanged(event); + } + + /** + * fireTreeNodesInserted + * + * @param source the node where new nodes got inserted + * @param path the path to the root node + * @param childIndices the indices of the new elements + * @param children the new elements + */ + protected void fireTreeNodesInserted(Object source, Object[] path, + int[] childIndices, Object[] children) + { + TreeModelEvent event = + new TreeModelEvent(source, path, childIndices, children); + TreeModelListener[] listeners = getTreeModelListeners(); + + for (int i = listeners.length - 1; i >= 0; --i) + listeners[i].treeNodesInserted(event); + } + + /** + * fireTreeNodesRemoved + * + * @param source the node where nodes got removed- + * @param path the path to the root node + * @param childIndices the indices of the removed elements + * @param children the removed elements + */ + protected void fireTreeNodesRemoved(Object source, Object[] path, + int[] childIndices, Object[] children) + { + TreeModelEvent event = + new TreeModelEvent(source, path, childIndices, children); + TreeModelListener[] listeners = getTreeModelListeners(); + + for (int i = listeners.length - 1; i >= 0; --i) + listeners[i].treeNodesRemoved(event); + } + + /** + * fireTreeStructureChanged + * + * @param source the node where the model has changed + * @param path the path to the root node + * @param childIndices the indices of the affected elements + * @param children the affected elements + */ + protected void fireTreeStructureChanged(Object source, Object[] path, + int[] childIndices, Object[] children) + { + TreeModelEvent event = + new TreeModelEvent(source, path, childIndices, children); + TreeModelListener[] listeners = getTreeModelListeners(); + + for (int i = listeners.length - 1; i >= 0; --i) + listeners[i].treeStructureChanged(event); + } + + /** + * Returns the registered listeners of a given type. + * + * @param listenerType the listener type to return + * + * @return an array of listeners + * + * @since 1.3 + */ + public EventListener[] getListeners(Class listenerType) + { + return listenerList.getListeners(listenerType); + } +} diff --git a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java index 79f642afc28..4fe69f4fb14 100644 --- a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java @@ -1,5 +1,5 @@ /* DefaultTreeSelectionModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,9 +45,10 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.EventListener; import java.util.Vector; + import javax.swing.DefaultListSelectionModel; -import javax.swing.event.SwingPropertyChangeSupport; import javax.swing.event.EventListenerList; +import javax.swing.event.SwingPropertyChangeSupport; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -60,402 +61,464 @@ public class DefaultTreeSelectionModel { static final long serialVersionUID = 3288129636638950196L; - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * SELECTION_MODE_PROPERTY - */ - public static final String SELECTION_MODE_PROPERTY = "selectionMode"; - - /** - * changeSupport - */ - protected SwingPropertyChangeSupport changeSupport; - - /** - * selection - */ - protected TreePath[] selection; - - /** - * listenerList - */ - protected EventListenerList listenerList; - - /** - * rowMapper - */ - protected transient RowMapper rowMapper; - - /** - * listSelectionModel - */ - protected DefaultListSelectionModel listSelectionModel; - - /** - * selectionMode - */ - protected int selectionMode; - - /** - * leadPath - */ - protected TreePath leadPath; - - /** - * leadIndex - */ - protected int leadIndex; - - /** - * leadRow - */ - protected int leadRow; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultTreeSelectionModel - */ - public DefaultTreeSelectionModel() { - // TODO - } // DefaultTreeSelectionModel() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * clone - * @exception CloneNotSupportedException TODO - * @returns Object - */ - public Object clone() throws CloneNotSupportedException { - return null; // TODO - } // clone() - - /** - * toString - * @returns String - */ - public String toString() { - return null; // TODO - } // toString() - - /** - * writeObject - * @param value0 TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream value0) throws IOException { - // TODO - } // writeObject() - - /** - * readObject - * @param value0 TODO - * @exception IOException TODO - * @exception ClassNotFoundException TODO - */ - private void readObject(ObjectInputStream value0) throws IOException, ClassNotFoundException { - // TODO - } // readObject() - - /** - * setRowMapper - * @param value0 TODO - */ - public void setRowMapper(RowMapper value0) { - // TODO - } // setRowMapper() - - /** - * getRowMapper - * @returns RowMapper - */ - public RowMapper getRowMapper() { - return null; // TODO - } // getRowMapper() - - /** - * setSelectionMode - * @param value0 TODO - */ - public void setSelectionMode(int value0) { - // TODO - } // setSelectionMode() - - /** - * getSelectionMode - * @returns int - */ - public int getSelectionMode() { - return 0; // TODO - } // getSelectionMode() - - /** - * setSelectionPath - * @param value0 TODO - */ - public void setSelectionPath(TreePath value0) { - // TODO - } // setSelectionPath() - - /** - * setSelectionPaths - * @param value0 TODO - */ - public void setSelectionPaths(TreePath[] value0) { - // TODO - } // setSelectionPaths() - - /** - * addSelectionPath - * @param value0 TODO - */ - public void addSelectionPath(TreePath value0) { - // TODO - } // addSelectionPath() - - /** - * addSelectionPaths - * @param value0 TODO - */ - public void addSelectionPaths(TreePath[] value0) { - // TODO - } // addSelectionPaths() - - /** - * removeSelectionPath - * @param value0 TODO - */ - public void removeSelectionPath(TreePath value0) { - // TODO - } // removeSelectionPath() - - /** - * removeSelectionPaths - * @param value0 TODO - */ - public void removeSelectionPaths(TreePath[] value0) { - // TODO - } // removeSelectionPaths() - - /** - * getSelectionPath - * @returns TreePath - */ - public TreePath getSelectionPath() { - return null; // TODO - } // getSelectionPath() - - /** - * getSelectionPaths - * @returns TreePath[] - */ - public TreePath[] getSelectionPaths() { - return null; // TODO - } // getSelectionPaths() - - /** - * getSelectionCount - * @returns int - */ - public int getSelectionCount() { - return 0; // TODO - } // getSelectionCount() - - /** - * isPathSelected - * @param value0 TODO - * @returns boolean - */ - public boolean isPathSelected(TreePath value0) { - return false; // TODO - } // isPathSelected() - - /** - * isSelectionEmpty - * @returns boolean - */ - public boolean isSelectionEmpty() { - return false; // TODO - } // isSelectionEmpty() - - /** - * clearSelection - */ - public void clearSelection() { - // TODO - } // clearSelection() - - /** - * addTreeSelectionListener - * @param value0 TODO - */ - public void addTreeSelectionListener(TreeSelectionListener value0) { - // TODO - } // addTreeSelectionListener() - - /** - * removeTreeSelectionListener - * @param value0 TODO - */ - public void removeTreeSelectionListener(TreeSelectionListener value0) { - // TODO - } // removeTreeSelectionListener() - - /** - * fireValueChanged - * @param value0 TODO - */ - protected void fireValueChanged(TreeSelectionEvent value0) { - // TODO - } // fireValueChanged() - - /** - * getListeners - * @param value0 TODO - * @returns EventListener[] - */ - public EventListener[] getListeners(Class value0) { - return null; // TODO - } // getListeners() - - /** - * getSelectionRows - * @returns int[] - */ - public int[] getSelectionRows() { - return null; // TODO - } // getSelectionRows() - - /** - * getMinSelectionRow - * @returns int - */ - public int getMinSelectionRow() { - return 0; // TODO - } // getMinSelectionRow() - - /** - * getMaxSelectionRow - * @returns int - */ - public int getMaxSelectionRow() { - return 0; // TODO - } // getMaxSelectionRow() - - /** - * isRowSelected - * @param value0 TODO - * @returns boolean - */ - public boolean isRowSelected(int value0) { - return false; // TODO - } // isRowSelected() - - /** - * resetRowSelection - */ - public void resetRowSelection() { - // TODO - } // resetRowSelection() - - /** - * getLeadSelectionRow - * @returns int - */ - public int getLeadSelectionRow() { - return 0; // TODO - } // getLeadSelectionRow() - - /** - * getLeadSelectionPath - * @returns TreePath - */ - public TreePath getLeadSelectionPath() { - return null; // TODO - } // getLeadSelectionPath() - - /** - * addPropertyChangeListener - * @param value0 TODO - */ - public synchronized void addPropertyChangeListener(PropertyChangeListener value0) { - // TODO - } // addPropertyChangeListener() - - /** - * removePropertyChangeListener - * @param value0 TODO - */ - public synchronized void removePropertyChangeListener(PropertyChangeListener value0) { - // TODO - } // removePropertyChangeListener() - - /** - * insureRowContinuity - */ - protected void insureRowContinuity() { - // TODO - } // insureRowContinuity() - - /** - * arePathsContiguous - * @param value0 TODO - * @returns boolean - */ - protected boolean arePathsContiguous(TreePath[] value0) { - return false; // TODO - } // arePathsContiguous() - - /** - * canPathsBeAdded - * @param value0 TODO - * @returns boolean - */ - protected boolean canPathsBeAdded(TreePath[] value0) { - return false; // TODO - } // canPathsBeAdded() - - /** - * canPathsBeRemoved - * @param value0 TODO - * @returns boolean - */ - protected boolean canPathsBeRemoved(TreePath[] value0) { - return false; // TODO - } // canPathsBeRemoved() - - /** - * notifyPathChange - * @param value0 TODO - * @param value1 TODO - */ - protected void notifyPathChange(Vector value0, TreePath value1) { - // TODO - } // notifyPathChange() - - /** - * updateLeadIndex - */ - protected void updateLeadIndex() { - // TODO - } // updateLeadIndex() - - /** - * insureUniqueness - */ - protected void insureUniqueness() { - // TODO - } // insureUniqueness() - - -} // DefaultTreeSelectionModel + /** + * SELECTION_MODE_PROPERTY + */ + public static final String SELECTION_MODE_PROPERTY = "selectionMode"; + + /** + * changeSupport + */ + protected SwingPropertyChangeSupport changeSupport; + + /** + * selection + */ + protected TreePath[] selection; + + /** + * listenerList + */ + protected EventListenerList listenerList; + + /** + * rowMapper + */ + protected transient RowMapper rowMapper; + + /** + * listSelectionModel + */ + protected DefaultListSelectionModel listSelectionModel; + + /** + * selectionMode + */ + protected int selectionMode; + + /** + * leadPath + */ + protected TreePath leadPath; + + /** + * leadIndex + */ + protected int leadIndex; + + /** + * leadRow + */ + protected int leadRow; + + /** + * Constructor DefaultTreeSelectionModel + */ + public DefaultTreeSelectionModel() + { + // TODO + } + + /** + * clone + * @exception CloneNotSupportedException TODO + * @return Object + */ + public Object clone() throws CloneNotSupportedException + { + return null; // TODO + } + + /** + * toString + * @return String + */ + public String toString() + { + return null; // TODO + } + + /** + * writeObject + * @param value0 TODO + * @exception IOException TODO + */ + private void writeObject(ObjectOutputStream value0) throws IOException + { + // TODO + } + + /** + * readObject + * @param value0 TODO + * @exception IOException TODO + * @exception ClassNotFoundException TODO + */ + private void readObject(ObjectInputStream value0) + throws IOException, ClassNotFoundException + { + // TODO + } + + /** + * setRowMapper + * @param value0 TODO + */ + public void setRowMapper(RowMapper value0) + { + // TODO + } + + /** + * getRowMapper + * @return RowMapper + */ + public RowMapper getRowMapper() + { + return null; // TODO + } + + /** + * setSelectionMode + * @param value0 TODO + */ + public void setSelectionMode(int value0) + { + // TODO + } + + /** + * getSelectionMode + * @return int + */ + public int getSelectionMode() + { + return 0; // TODO + } + + /** + * setSelectionPath + * @param value0 TODO + */ + public void setSelectionPath(TreePath value0) + { + // TODO + } + + /** + * setSelectionPaths + * @param value0 TODO + */ + public void setSelectionPaths(TreePath[] value0) + { + // TODO + } + + /** + * addSelectionPath + * @param value0 TODO + */ + public void addSelectionPath(TreePath value0) + { + // TODO + } + + /** + * addSelectionPaths + * @param value0 TODO + */ + public void addSelectionPaths(TreePath[] value0) + { + // TODO + } + + /** + * removeSelectionPath + * @param value0 TODO + */ + public void removeSelectionPath(TreePath value0) + { + // TODO + } + + /** + * removeSelectionPaths + * @param value0 TODO + */ + public void removeSelectionPaths(TreePath[] value0) + { + // TODO + } + + /** + * getSelectionPath + * @return TreePath + */ + public TreePath getSelectionPath() + { + return null; // TODO + } + + /** + * getSelectionPaths + * @return TreePath[] + */ + public TreePath[] getSelectionPaths() + { + return null; // TODO + } + + /** + * getSelectionCount + * @return int + */ + public int getSelectionCount() + { + return 0; // TODO + } + + /** + * isPathSelected + * @param value0 TODO + * @return boolean + */ + public boolean isPathSelected(TreePath value0) + { + return false; // TODO + } + + /** + * isSelectionEmpty + * @return boolean + */ + public boolean isSelectionEmpty() + { + return false; // TODO + } + + /** + * clearSelection + */ + public void clearSelection() + { + // TODO + } + + /** + * Adds a <code>TreeSelectionListener</code> object to this model. + * + * @param listener the listener to add + */ + public void addTreeSelectionListener(TreeSelectionListener listener) + { + listenerList.add(TreeSelectionListener.class, listener); + } + + /** + * Removes a <code>TreeSelectionListener</code> object from this model. + * + * @param listener the listener to remove + */ + public void removeTreeSelectionListener(TreeSelectionListener listener) + { + listenerList.remove(TreeSelectionListener.class, listener); + } + + /** + * Returns all <code>TreeSelectionListener</code> added to this model. + * + * @return an array of listeners + * + * @since 1.4 + */ + public TreeSelectionListener[] getTreeSelectionListeners() + { + return (TreeSelectionListener[]) listenerList.getListeners(TreeSelectionListener.class); + } + + /** + * fireValueChanged + * + * @param event the event to fire. + */ + protected void fireValueChanged(TreeSelectionEvent event) + { + TreeSelectionListener[] listeners = getTreeSelectionListeners(); + + for (int i = listeners.length - 1; i >= 0; --i) + listeners[i].valueChanged(event); + } + + /** + * Returns all added listeners of a special type. + * + * @param listenerType the listener type + * + * @return an array of listeners + * + * @since 1.3 + */ + public EventListener[] getListeners(Class listenerType) + { + return listenerList.getListeners(listenerType); + } + + /** + * getSelectionRows + * @return int[] + */ + public int[] getSelectionRows() + { + return null; // TODO + } + + /** + * getMinSelectionRow + * @return int + */ + public int getMinSelectionRow() + { + return 0; // TODO + } + + /** + * getMaxSelectionRow + * @return int + */ + public int getMaxSelectionRow() + { + return 0; // TODO + } + + /** + * isRowSelected + * @param value0 TODO + * @return boolean + */ + public boolean isRowSelected(int value0) + { + return false; // TODO + } + + /** + * resetRowSelection + */ + public void resetRowSelection() + { + // TODO + } + + /** + * getLeadSelectionRow + * @return int + */ + public int getLeadSelectionRow() + { + return 0; // TODO + } + + /** + * getLeadSelectionPath + * @return TreePath + */ + public TreePath getLeadSelectionPath() + { + return null; // TODO + } + + /** + * Adds a <code>PropertyChangeListener</code> object to this model. + * + * @param listener the listener to add. + */ + public void addPropertyChangeListener(PropertyChangeListener listener) + { + changeSupport.addPropertyChangeListener(listener); + } + + /** + * Removes a <code>PropertyChangeListener</code> object from this model. + * + * @param listener the listener to remove. + */ + public void removePropertyChangeListener(PropertyChangeListener listener) + { + changeSupport.removePropertyChangeListener(listener); + } + + /** + * Returns all added <code>PropertyChangeListener</code> objects. + * + * @return an array of listeners. + * + * @since 1.4 + */ + public PropertyChangeListener[] getPropertyChangeListeners() + { + return changeSupport.getPropertyChangeListeners(); + } + + /** + * insureRowContinuity + */ + protected void insureRowContinuity() + { + // TODO + } + + /** + * arePathsContiguous + * @param value0 TODO + * @return boolean + */ + protected boolean arePathsContiguous(TreePath[] value0) + { + return false; // TODO + } + + /** + * canPathsBeAdded + * @param value0 TODO + * @return boolean + */ + protected boolean canPathsBeAdded(TreePath[] value0) + { + return false; // TODO + } + + /** + * canPathsBeRemoved + * @param value0 TODO + * @return boolean + */ + protected boolean canPathsBeRemoved(TreePath[] value0) + { + return false; // TODO + } + + /** + * notifyPathChange + * @param value0 TODO + * @param value1 TODO + */ + protected void notifyPathChange(Vector value0, TreePath value1) + { + // TODO + } + + /** + * updateLeadIndex + */ + protected void updateLeadIndex() + { + // TODO + } + + /** + * insureUniqueness + */ + protected void insureUniqueness() + { + // TODO + } +} diff --git a/libjava/javax/swing/tree/FixedHeightLayoutCache.java b/libjava/javax/swing/tree/FixedHeightLayoutCache.java index dae34229c3a..5cb6d3a2a9f 100644 --- a/libjava/javax/swing/tree/FixedHeightLayoutCache.java +++ b/libjava/javax/swing/tree/FixedHeightLayoutCache.java @@ -1,5 +1,5 @@ /* FixedHeightLayoutCache.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing.tree; import java.awt.Rectangle; import java.util.Enumeration; + import javax.swing.event.TreeModelEvent; /** diff --git a/libjava/javax/swing/tree/TreeCellEditor.java b/libjava/javax/swing/tree/TreeCellEditor.java index bdc0b5d6468..d9de676dd8d 100644 --- a/libjava/javax/swing/tree/TreeCellEditor.java +++ b/libjava/javax/swing/tree/TreeCellEditor.java @@ -1,5 +1,5 @@ /* TreeCellEditor.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,14 +39,16 @@ exception statement from your version. */ package javax.swing.tree; import java.awt.Component; + +import javax.swing.CellEditor; import javax.swing.JTree; /** * TreeCellEditor public interface * @author Andrew Selkirk */ -public interface TreeCellEditor { - +public interface TreeCellEditor extends CellEditor +{ /** * getTreeCellEditorComponent * @param tree TODO diff --git a/libjava/javax/swing/tree/TreeCellRenderer.java b/libjava/javax/swing/tree/TreeCellRenderer.java index 3be8870ece5..ebd173efa3d 100644 --- a/libjava/javax/swing/tree/TreeCellRenderer.java +++ b/libjava/javax/swing/tree/TreeCellRenderer.java @@ -1,5 +1,5 @@ /* TreeCellRenderer.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,10 +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.tree; -// Imports import java.awt.Component; + import javax.swing.JTree; /** diff --git a/libjava/javax/swing/tree/TreeSelectionModel.java b/libjava/javax/swing/tree/TreeSelectionModel.java index 85dfe29a9cc..c72617bff81 100644 --- a/libjava/javax/swing/tree/TreeSelectionModel.java +++ b/libjava/javax/swing/tree/TreeSelectionModel.java @@ -1,5 +1,5 @@ /* TreeSelectionModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.tree; import java.beans.PropertyChangeListener; + import javax.swing.event.TreeSelectionListener; /** diff --git a/libjava/javax/swing/tree/VariableHeightLayoutCache.java b/libjava/javax/swing/tree/VariableHeightLayoutCache.java index 445faa9c230..14e6ea9025e 100644 --- a/libjava/javax/swing/tree/VariableHeightLayoutCache.java +++ b/libjava/javax/swing/tree/VariableHeightLayoutCache.java @@ -1,5 +1,5 @@ /* VariableHeightLayoutCache.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,7 @@ package javax.swing.tree; import java.awt.Rectangle; import java.util.Enumeration; + import javax.swing.event.TreeModelEvent; /** diff --git a/libjava/javax/swing/undo/AbstractUndoableEdit.java b/libjava/javax/swing/undo/AbstractUndoableEdit.java index e694c0a447f..5ba68f58090 100644 --- a/libjava/javax/swing/undo/AbstractUndoableEdit.java +++ b/libjava/javax/swing/undo/AbstractUndoableEdit.java @@ -1,5 +1,5 @@ -/* AbstractUndoableEdit.java - Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* AbstractUndoableEdit.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.undo; import java.io.Serializable; -import javax.swing.UIManager; +import javax.swing.UIManager; /** * A default implementation of <code>UndoableEdit</code> that can be diff --git a/libjava/javax/swing/undo/UndoableEditSupport.java b/libjava/javax/swing/undo/UndoableEditSupport.java index 7f7bb8e83e7..8b4cef77588 100644 --- a/libjava/javax/swing/undo/UndoableEditSupport.java +++ b/libjava/javax/swing/undo/UndoableEditSupport.java @@ -40,10 +40,10 @@ package javax.swing.undo; import java.util.Iterator; import java.util.Vector; + import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; - /** * A helper class for supporting {@link * javax.swing.event.UndoableEditListener}. |