diff options
Diffstat (limited to 'java')
35 files changed, 818 insertions, 417 deletions
diff --git a/java/awt/Adjustable.java b/java/awt/Adjustable.java index 58116e4e5..e20344277 100644 --- a/java/awt/Adjustable.java +++ b/java/awt/Adjustable.java @@ -51,13 +51,13 @@ import java.awt.event.AdjustmentListener; public interface Adjustable { /** Constant for an adjustable object with horizontal orientation. */ - int HORIZONTAL = 0; + static final int HORIZONTAL = 0; /** Constant for an adjustable object with vertical orientation. */ - int VERTICAL = 1; + static final int VERTICAL = 1; /** Constant for an adjustable object with no orientation. */ - int NO_ORIENTATION = 2; + static final int NO_ORIENTATION = 2; /** * Returns a constant representing the orientation of the object. diff --git a/java/awt/AlphaComposite.java b/java/awt/AlphaComposite.java index 14649fc74..f0795a960 100644 --- a/java/awt/AlphaComposite.java +++ b/java/awt/AlphaComposite.java @@ -64,6 +64,7 @@ public final class AlphaComposite implements Composite return size() > MAX_CACHE_SIZE; } }; + public static final int CLEAR = 1; public static final int SRC = 2; public static final int DST = 9; @@ -88,6 +89,7 @@ public final class AlphaComposite implements Composite public static final AlphaComposite SrcAtop = getInstance(SRC_ATOP); public static final AlphaComposite DstAtop = getInstance(DST_ATOP); public static final AlphaComposite Xor = getInstance(XOR); + private final int rule; private final float alpha; private AlphaComposite(int rule, float alpha) @@ -95,10 +97,32 @@ public final class AlphaComposite implements Composite this.rule = rule; this.alpha = alpha; } + + /** + * Creates an AlphaComposite object with the specified rule. + * + * @param rule The compositing rule. + * + * @exception IllegalArgumentException If rule is not one of the following: + * CLEAR, SRC, DST, SRC_OVER, DST_OVER, SRC_IN, DST_IN, SRC_OUT, DST_OUT, + * SRC_ATOP, DST_ATOP, or XOR. + */ public static AlphaComposite getInstance(int rule) { return getInstance(rule, 1); } + + /** + * Creates an AlphaComposite object with the specified rule and the constant + * alpha to multiply with the alpha of the source. The source is multiplied + * with the specified alpha before being composited with the destination. + * + * @param rule The compositing rule. + * + * @exception IllegalArgumentException If rule is not one of the following: + * CLEAR, SRC, DST, SRC_OVER, DST_OVER, SRC_IN, DST_IN, SRC_OUT, DST_OUT, + * SRC_ATOP, DST_ATOP, or XOR. + */ public static AlphaComposite getInstance(int rule, float alpha) { if (rule < CLEAR || rule > XOR || ! (alpha >= 0 && alpha <= 1)) diff --git a/java/awt/BasicStroke.java b/java/awt/BasicStroke.java index c3290336c..598c0d430 100644 --- a/java/awt/BasicStroke.java +++ b/java/awt/BasicStroke.java @@ -59,12 +59,31 @@ public class BasicStroke implements Stroke private final float[] dash; private final float phase; + /** + * Creates a basic stroke. + * + * @param width May not be negative . + * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE. + * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER. + * @param miterlimit the limit to trim the miter join. The miterlimit must be + * greater than or equal to 1.0f. + * @param dash The array representing the dashing pattern. + * @param dash_phase is negative and dash is not null. + * + * @exception IllegalArgumentException If one input parameter doesn't meet + * its needs. + */ public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dashPhase) { - if (width < 0 || miterlimit < 1 || cap < CAP_BUTT || cap > CAP_SQUARE - || join < JOIN_MITER || join > JOIN_BEVEL) + if (width < 0 || + miterlimit < 1.0f || + cap < CAP_BUTT || + cap > CAP_SQUARE || + join < JOIN_MITER || + join > JOIN_BEVEL) throw new IllegalArgumentException(); + this.width = width; this.cap = cap; this.join = join; @@ -73,21 +92,54 @@ public class BasicStroke implements Stroke phase = dashPhase; } + /** + * Creates a basicc stroke. + * + * @param width The width of the BasicStroke. May not be negative . + * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE. + * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER. + * @param miterlimit the limit to trim the miter join. The miterlimit must be + * greater than or equal to 1.0f. + * + * @exception IllegalArgumentException If one input parameter doesn't meet + * its needs. + */ public BasicStroke(float width, int cap, int join, float miterlimit) { this(width, cap, join, miterlimit, null, 0); } + /** + * Creates a basicc stroke. + * + * @param width The width of the BasicStroke. May not be nehative. + * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE. + * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER. + * + * @exception IllegalArgumentException If one input parameter doesn't meet + * its needs. + * @exception IllegalArgumentException FIXME + */ public BasicStroke(float width, int cap, int join) { this(width, cap, join, 10, null, 0); } + /** + * Creates a basicc stroke. + * + * @param width The width of the BasicStroke. + * + * @exception IllegalArgumentException If width is negative. + */ public BasicStroke(float width) { this(width, CAP_SQUARE, JOIN_MITER, 10, null, 0); } + /** + * Creates a basicc stroke. + */ public BasicStroke() { this(1, CAP_SQUARE, JOIN_MITER, 10, null, 0); diff --git a/java/awt/BufferCapabilities.java b/java/awt/BufferCapabilities.java index 389594b76..871529e6e 100644 --- a/java/awt/BufferCapabilities.java +++ b/java/awt/BufferCapabilities.java @@ -67,6 +67,11 @@ public class BufferCapabilities implements Cloneable private final ImageCapabilities back; private final FlipContents flip; + /** + * Creates a buffer capabilities object. + * + * @exception IllegalArgumentException If frontCaps or backCaps are null. + */ public BufferCapabilities(ImageCapabilities front, ImageCapabilities back, FlipContents flip) { diff --git a/java/awt/Button.java b/java/awt/Button.java index ed954ddcf..989fbc951 100644 --- a/java/awt/Button.java +++ b/java/awt/Button.java @@ -90,6 +90,9 @@ private transient ActionListener action_listeners; /** * Initializes a new instance of <code>Button</code> with no label. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true */ public Button() @@ -104,12 +107,18 @@ Button() * label. The action command name is also initialized to this value. * * @param label The label to display on the button. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true */ public Button(String label) { this.label = label; actionCommand = label; + + if (GraphicsEnvironment.isHeadless ()) + throw new HeadlessException (); } /*************************************************************************/ @@ -211,6 +220,10 @@ removeActionListener(ActionListener listener) /** Returns all registered EventListers of the given listenerType. * listenerType must be a subclass of EventListener, or a * ClassClassException is thrown. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements @see java.util.EventListener. + * * @since 1.3 */ public EventListener[] getListeners(Class listenerType) diff --git a/java/awt/CheckboxMenuItem.java b/java/awt/CheckboxMenuItem.java index 2f7ecd79f..88218397c 100644 --- a/java/awt/CheckboxMenuItem.java +++ b/java/awt/CheckboxMenuItem.java @@ -84,6 +84,9 @@ private transient ItemListener item_listeners; /** * Initializes a new instance of <code>CheckboxMenuItem</code> with no * label and an initial state of off. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. */ public CheckboxMenuItem() @@ -98,6 +101,9 @@ CheckboxMenuItem() * specified label and an initial state of off. * * @param label The label of the menu item. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. */ public CheckboxMenuItem(String label) @@ -114,12 +120,18 @@ CheckboxMenuItem(String label) * @param label The label of the menu item. * @param state The initial state of the menu item, where <code>true</code> * is on, and <code>false</code> is off. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. */ public CheckboxMenuItem(String label, boolean state) { super(label); this.state = state; + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/Choice.java b/java/awt/Choice.java index 81a2a31c9..4c7b50553 100644 --- a/java/awt/Choice.java +++ b/java/awt/Choice.java @@ -85,13 +85,17 @@ private ItemListener item_listeners; * Constructors */ -/** - * Initializes a new instance of <code>Choice</code>. - */ -public -Choice() -{ -} + /** + * Initializes a new instance of <code>Choice</code>. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true + */ + public Choice() + { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); + } /*************************************************************************/ @@ -146,12 +150,16 @@ getItem(int index) * Adds the specified item to this choice box. * * @param item The item to add. + * + * @exception NullPointerException If the item's value is null + * + * @since 1.1 */ public synchronized void add(String item) { if (item == null) - throw new IllegalArgumentException ("item must be non-null"); + throw new NullPointerException ("item must be non-null"); pItems.addElement(item); @@ -171,7 +179,12 @@ add(String item) /** * Adds the specified item to this choice box. * + * This method is oboslete since Java 2 platform 1.1. Please use @see add + * instead. + * * @param item The item to add. + * + * @exception NullPointerException If the item's value is equal to null */ public synchronized void addItem(String item) @@ -189,10 +202,15 @@ addItem(String item) * * @param item The item to add. * @param index The index at which the item should be inserted. + * + * @exception IllegalArgumentException If index is less than 0 */ public synchronized void insert(String item, int index) { + if (index < 0) + throw new IllegalArgumentException ("index may not be less then 0"); + if (index > getItemCount ()) index = getItemCount (); diff --git a/java/awt/Container.java b/java/awt/Container.java index dd2390d35..9494d8c56 100644 --- a/java/awt/Container.java +++ b/java/awt/Container.java @@ -59,7 +59,9 @@ import javax.accessibility.Accessible; * * @author original author unknown * @author Eric Blake <ebb9@email.byu.edu> + * * @since 1.0 + * * @status still missing 1.4 support */ public class Container extends Component @@ -78,7 +80,9 @@ public class Container extends Component Dimension maxSize; - /** @since 1.4 */ + /** + * @since 1.4 + */ boolean focusCycleRoot; int containerSerializedDataVersion; @@ -107,6 +111,7 @@ public class Container extends Component * Returns the number of components in this container. * * @return The number of components in this container. + * * @deprecated use {@link #getComponentCount()} instead */ public int countComponents() @@ -118,16 +123,19 @@ public class Container extends Component * Returns the component at the specified index. * * @param index The index of the component to retrieve. + * * @return The requested component. + * * @throws ArrayIndexOutOfBoundsException If the specified index is invalid */ public Component getComponent(int n) { synchronized (getTreeLock ()) { - if (n < 0 || n >= ncomponents) - throw new ArrayIndexOutOfBoundsException("no such component"); - return component[n]; + if (n < 0 || n >= ncomponents) + throw new ArrayIndexOutOfBoundsException("no such component"); + + return component[n]; } } @@ -140,10 +148,12 @@ public class Container extends Component { synchronized (getTreeLock ()) { - Component[] result = new Component[ncomponents]; - if (ncomponents > 0) - System.arraycopy(component, 0, result, 0, ncomponents); - return result; + Component[] result = new Component[ncomponents]; + + if (ncomponents > 0) + System.arraycopy(component, 0, result, 0, ncomponents); + + return result; } } @@ -157,6 +167,7 @@ public class Container extends Component { if (peer == null) return new Insets(0, 0, 0, 0); + return ((ContainerPeer) peer).getInsets(); } @@ -177,6 +188,7 @@ public class Container extends Component * component list. * * @param component The component to add to the container. + * * @return The same component that was added. */ public Component add(Component comp) @@ -190,7 +202,7 @@ public class Container extends Component * component list. This method should not be used. Instead, use * <code>add(Component, Object</code>. * - * @param name FIXME + * @param name The name of the component to be added. * @param component The component to be added. * * @return The same component that was added. @@ -268,69 +280,70 @@ public class Container extends Component { synchronized (getTreeLock ()) { - if (index > ncomponents - || (index < 0 && index != -1) - || comp instanceof Window - || (comp instanceof Container - && ((Container) comp).isAncestorOf(this))) - throw new IllegalArgumentException(); - - // Reparent component, and make sure component is instantiated if - // we are. - if (comp.parent != null) - comp.parent.remove(comp); - comp.parent = this; - if (peer != null) - { - comp.addNotify(); - - if (comp.isLightweight()) - enableEvents(comp.eventMask); - } + if (index > ncomponents + || (index < 0 && index != -1) + || comp instanceof Window + || (comp instanceof Container + && ((Container) comp).isAncestorOf(this))) + throw new IllegalArgumentException(); + + // Reparent component, and make sure component is instantiated if + // we are. + if (comp.parent != null) + comp.parent.remove(comp); + comp.parent = this; + if (peer != null) + { + comp.addNotify(); - invalidate(); + if (comp.isLightweight()) + enableEvents(comp.eventMask); + } - if (component == null) - component = new Component[4]; // FIXME, better initial size? + invalidate(); - // This isn't the most efficient implementation. We could do less - // copying when growing the array. It probably doesn't matter. - if (ncomponents >= component.length) - { - int nl = component.length * 2; - Component[] c = new Component[nl]; - System.arraycopy(component, 0, c, 0, ncomponents); - component = c; - } - if (index == -1) - component[ncomponents++] = comp; - else - { - System.arraycopy(component, index, component, index + 1, - ncomponents - index); - component[index] = comp; - ++ncomponents; - } + if (component == null) + component = new Component[4]; // FIXME, better initial size? - // Notify the layout manager. - if (layoutMgr != null) - { - if (layoutMgr instanceof LayoutManager2) - { - LayoutManager2 lm2 = (LayoutManager2) layoutMgr; - lm2.addLayoutComponent(comp, constraints); - } - else if (constraints instanceof String) - layoutMgr.addLayoutComponent((String) constraints, comp); - else - layoutMgr.addLayoutComponent(null, comp); - } + // This isn't the most efficient implementation. We could do less + // copying when growing the array. It probably doesn't matter. + if (ncomponents >= component.length) + { + int nl = component.length * 2; + Component[] c = new Component[nl]; + System.arraycopy(component, 0, c, 0, ncomponents); + component = c; + } + + if (index == -1) + component[ncomponents++] = comp; + else + { + System.arraycopy(component, index, component, index + 1, + ncomponents - index); + component[index] = comp; + ++ncomponents; + } - // Post event to notify of adding the container. - ContainerEvent ce = new ContainerEvent(this, - ContainerEvent.COMPONENT_ADDED, - comp); - getToolkit().getSystemEventQueue().postEvent(ce); + // Notify the layout manager. + if (layoutMgr != null) + { + if (layoutMgr instanceof LayoutManager2) + { + LayoutManager2 lm2 = (LayoutManager2) layoutMgr; + lm2.addLayoutComponent(comp, constraints); + } + else if (constraints instanceof String) + layoutMgr.addLayoutComponent((String) constraints, comp); + else + layoutMgr.addLayoutComponent(null, comp); + } + + // Post event to notify of adding the container. + ContainerEvent ce = new ContainerEvent(this, + ContainerEvent.COMPONENT_ADDED, + comp); + getToolkit().getSystemEventQueue().postEvent(ce); } } @@ -343,24 +356,24 @@ public class Container extends Component { synchronized (getTreeLock ()) { - Component r = component[index]; + Component r = component[index]; - r.removeNotify(); + r.removeNotify(); - System.arraycopy(component, index + 1, component, index, - ncomponents - index - 1); - component[--ncomponents] = null; + System.arraycopy(component, index + 1, component, index, + ncomponents - index - 1); + component[--ncomponents] = null; - invalidate(); + invalidate(); - if (layoutMgr != null) - layoutMgr.removeLayoutComponent(r); + if (layoutMgr != null) + layoutMgr.removeLayoutComponent(r); - // Post event to notify of adding the container. - ContainerEvent ce = new ContainerEvent(this, - ContainerEvent.COMPONENT_REMOVED, - r); - getToolkit().getSystemEventQueue().postEvent(ce); + // Post event to notify of adding the container. + ContainerEvent ce = new ContainerEvent(this, + ContainerEvent.COMPONENT_REMOVED, + r); + getToolkit().getSystemEventQueue().postEvent(ce); } } @@ -373,14 +386,14 @@ public class Container extends Component { synchronized (getTreeLock ()) { - for (int i = 0; i < ncomponents; ++i) - { - if (component[i] == comp) - { - remove(i); - break; - } - } + for (int i = 0; i < ncomponents; ++i) + { + if (component[i] == comp) + { + remove(i); + break; + } + } } } @@ -391,8 +404,8 @@ public class Container extends Component { synchronized (getTreeLock ()) { - while (ncomponents > 0) - remove(0); + while (ncomponents > 0) + remove(0); } } @@ -525,6 +538,7 @@ public class Container extends Component * Returns the preferred size of this container. * * @return The preferred size of this container. + * * @deprecated use {@link #getPreferredSize()} instead */ public Dimension preferredSize() @@ -549,6 +563,7 @@ public class Container extends Component * Returns the minimum size of this container. * * @return The minimum size of this container. + * * @deprecated use {@link #getMinimumSize()} instead */ public Dimension minimumSize() @@ -709,6 +724,10 @@ public class Container extends Component } /** + * Returns an array of all the objects currently registered as FooListeners + * upon this Container. FooListeners are registered using the addFooListener + * method. + * * @since 1.3 */ public EventListener[] getListeners(Class listenerType) @@ -760,6 +779,7 @@ public class Container extends Component * AWT 1.0 event processor. * * @param event The event that occurred. + * * @deprecated use {@link #dispatchEvent(AWTEvent)} instead */ public void deliverEvent(Event e) @@ -784,20 +804,20 @@ public class Container extends Component { synchronized (getTreeLock ()) { - if (! contains(x, y)) - return null; - for (int i = 0; i < ncomponents; ++i) - { - // Ignore invisible children... - if (!component[i].isVisible()) - continue; - - int x2 = x - component[i].x; - int y2 = y - component[i].y; - if (component[i].contains(x2, y2)) - return component[i]; - } - return this; + if (! contains(x, y)) + return null; + for (int i = 0; i < ncomponents; ++i) + { + // Ignore invisible children... + if (!component[i].isVisible()) + continue; + + int x2 = x - component[i].x; + int y2 = y - component[i].y; + if (component[i].contains(x2, y2)) + return component[i]; + } + return this; } } @@ -813,6 +833,7 @@ public class Container extends Component * * @return The component containing the specified point, or <code>null</code> * if there is no such point. + * * @deprecated use {@link #getComponentAt(int, int)} instead */ public Component locate(int x, int y) @@ -841,31 +862,31 @@ public class Container extends Component { synchronized (getTreeLock ()) { - if (! contains(x, y)) - return null; - - for (int i = 0; i < ncomponents; ++i) - { - // Ignore invisible children... - if (!component[i].isVisible()) - continue; - - int x2 = x - component[i].x; - int y2 = y - component[i].y; - // We don't do the contains() check right away because - // findComponentAt would redundantly do it first thing. - if (component[i] instanceof Container) - { - Container k = (Container) component[i]; - Component r = k.findComponentAt(x2, y2); - if (r != null) - return r; - } - else if (component[i].contains(x2, y2)) - return component[i]; - } + if (! contains(x, y)) + return null; - return this; + for (int i = 0; i < ncomponents; ++i) + { + // Ignore invisible children... + if (!component[i].isVisible()) + continue; + + int x2 = x - component[i].x; + int y2 = y - component[i].y; + // We don't do the contains() check right away because + // findComponentAt would redundantly do it first thing. + if (component[i] instanceof Container) + { + Container k = (Container) component[i]; + Component r = k.findComponentAt(x2, y2); + if (r != null) + return r; + } + else if (component[i].contains(x2, y2)) + return component[i]; + } + + return this; } } @@ -894,9 +915,9 @@ public class Container extends Component { synchronized (getTreeLock ()) { - for (int i = 0; i < ncomponents; ++i) - component[i].removeNotify(); - super.removeNotify(); + for (int i = 0; i < ncomponents; ++i) + component[i].removeNotify(); + super.removeNotify(); } } @@ -913,14 +934,14 @@ public class Container extends Component { synchronized (getTreeLock ()) { - while (true) - { - if (comp == null) - return false; - if (comp == this) - return true; - comp = comp.getParent(); - } + while (true) + { + if (comp == null) + return false; + if (comp == this) + return true; + comp = comp.getParent(); + } } } @@ -950,9 +971,9 @@ public class Container extends Component { synchronized (getTreeLock ()) { - super.list(out, indent); - for (int i = 0; i < ncomponents; ++i) - component[i].list(out, indent + 2); + super.list(out, indent); + for (int i = 0; i < ncomponents; ++i) + component[i].list(out, indent + 2); } } @@ -967,62 +988,93 @@ public class Container extends Component { synchronized (getTreeLock ()) { - super.list(out, indent); - for (int i = 0; i < ncomponents; ++i) - component[i].list(out, indent + 2); + super.list(out, indent); + for (int i = 0; i < ncomponents; ++i) + component[i].list(out, indent + 2); } } public void setFocusTraversalKeys(int id, Set keys) { + if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS && + id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS) + throw new IllegalArgumentException (); } + public Set getFocusTraversalKeys(int id) { + if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS && + id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS) + throw new IllegalArgumentException (); + return null; } + public boolean areFocusTraversalKeysSet(int id) { + if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS && + id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS && + id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS) + throw new IllegalArgumentException (); + return false; } + public boolean isFocusCycleRoot(Container c) { return false; } + public void transferFocusBackward() { } + public void setFocusTraversalPolicy(FocusTraversalPolicy policy) { } + public FocusTraversalPolicy getFocusTraversalPolicy() { return null; } + public boolean isFocusTraversalPolicySet() { return false; } + public void setFocusCycleRoot(boolean focusCycleRoot) { } + public boolean isFocusCycleRoot() { return false; } + public void transferFocusDownCycle() { } + public void applyComponentOrientation(ComponentOrientation o) { + if (orientation == null) + throw new NullPointerException (); } + public void addPropertyChangeListener(PropertyChangeListener l) { } + public void addPropertyChangeListener(String name, PropertyChangeListener l) { } - // Hidden helper methods. /** @@ -1044,14 +1096,14 @@ public class Container extends Component { synchronized (getTreeLock ()) { - for (int i = 0; i < ncomponents; ++i) - { - Component comp = component[i]; - boolean applicable = comp.isVisible() - && (comp.isLightweight() || !lightweightOnly); - - if (applicable) - visitChild(gfx, visitor, comp); + for (int i = 0; i < ncomponents; ++i) + { + Component comp = component[i]; + boolean applicable = comp.isVisible() + && (comp.isLightweight() || !lightweightOnly); + + if (applicable) + visitChild(gfx, visitor, comp); } } } @@ -1100,50 +1152,50 @@ public class Container extends Component { synchronized (getTreeLock ()) { - int start, end; - if (child != null) - { - for (start = 0; start < ncomponents; ++start) - { - if (component[start] == child) - break; - } - end = start; - // This special case lets us be sure to terminate. - if (end == 0) - end = ncomponents; - ++start; - } - else - { - start = 0; - end = ncomponents; - } + int start, end; + if (child != null) + { + for (start = 0; start < ncomponents; ++start) + { + if (component[start] == child) + break; + } + end = start; + // This special case lets us be sure to terminate. + if (end == 0) + end = ncomponents; + ++start; + } + else + { + start = 0; + end = ncomponents; + } - for (int j = start; j != end; ++j) - { - if (j >= ncomponents) - { - // The JCL says that we should wrap here. However, that - // seems wrong. To me it seems that focus order should be - // global within in given window. So instead if we reach - // the end we try to look in our parent, if we have one. - if (parent != null) - return parent.findNextFocusComponent(this); - j -= ncomponents; - } - if (component[j] instanceof Container) - { - Component c = component[j]; - c = c.findNextFocusComponent(null); - if (c != null) - return c; - } - else if (component[j].isFocusTraversable()) - return component[j]; - } + for (int j = start; j != end; ++j) + { + if (j >= ncomponents) + { + // The JCL says that we should wrap here. However, that + // seems wrong. To me it seems that focus order should be + // global within in given window. So instead if we reach + // the end we try to look in our parent, if we have one. + if (parent != null) + return parent.findNextFocusComponent(this); + j -= ncomponents; + } + if (component[j] instanceof Container) + { + Component c = component[j]; + c = c.findNextFocusComponent(null); + if (c != null) + return c; + } + else if (component[j].isFocusTraversable()) + return component[j]; + } - return null; + return null; } } @@ -1151,16 +1203,15 @@ public class Container extends Component { synchronized (getTreeLock ()) { - for (int i = ncomponents; --i >= 0; ) - { - component[i].addNotify(); - if (component[i].isLightweight()) - enableEvents(component[i].eventMask); - } + for (int i = ncomponents; --i >= 0; ) + { + component[i].addNotify(); + if (component[i].isLightweight()) + enableEvents(component[i].eventMask); + } } } - // Nested classes. /* The following classes are used in concert with the @@ -1200,6 +1251,7 @@ public class Container extends Component * This class provides accessibility support for subclasses of container. * * @author Eric Blake <ebb9@email.byu.edu> + * * @since 1.3 */ protected class AccessibleAWTContainer extends AccessibleAWTComponent @@ -1234,14 +1286,14 @@ public class Container extends Component public int getAccessibleChildrenCount() { synchronized (getTreeLock ()) - { - int count = 0; - int i = component == null ? 0 : component.length; - while (--i >= 0) - if (component[i] instanceof Accessible) - count++; - return count; - } + { + int count = 0; + int i = component == null ? 0 : component.length; + while (--i >= 0) + if (component[i] instanceof Accessible) + count++; + return count; + } } /** @@ -1253,17 +1305,17 @@ public class Container extends Component public Accessible getAccessibleChild(int i) { synchronized (getTreeLock ()) - { - if (component == null) - return null; - int index = -1; - while (i >= 0 && ++index < component.length) - if (component[index] instanceof Accessible) - i--; - if (i < 0) - return (Accessible) component[index]; - return null; - } + { + if (component == null) + return null; + int index = -1; + while (i >= 0 && ++index < component.length) + if (component[index] instanceof Accessible) + i--; + if (i < 0) + return (Accessible) component[index]; + return null; + } } /** @@ -1271,7 +1323,9 @@ public class Container extends Component * coordinates), if one exists. * * @param p the point to look at + * * @return an accessible object at that point, or null + * * @throws NullPointerException if p is null */ public Accessible getAccessibleAt(Point p) @@ -1286,6 +1340,7 @@ public class Container extends Component * when children are added or removed from the enclosing accessible object. * * @author Eric Blake <ebb9@email.byu.edu> + * * @since 1.3 */ protected class AccessibleContainerHandler implements ContainerListener @@ -1324,7 +1379,6 @@ public class Container extends Component } // class AccessibleAWTPanel } // class Container - /** * Undocumented helper class. * STUBBED @@ -1339,39 +1393,50 @@ class LightweightDispatcher implements Serializable, AWTEventListener private transient boolean isMouseInNativeContainer; private Cursor nativeCursor; private long eventMask; + LightweightDispatcher(Container c) { } + void dispose() { } + void enableEvents(long l) { } + boolean dispatchEvent(AWTEvent e) { return true; } + boolean isMouseGrab(MouseEvent e) { return true; } + boolean processMouseEvent(MouseEvent e) { return true; } + void trackMouseEnterExit(Component c, MouseEvent e) { } + void startListeningForOtherDrags() { } + void stopListeningForOtherDrags() { } + public void eventDispatched(AWTEvent e) { } + void retargetMouseEvent(Component c, int i, MouseEvent e) { } diff --git a/java/awt/Cursor.java b/java/awt/Cursor.java index 5852b8bbf..8652a1e5e 100644 --- a/java/awt/Cursor.java +++ b/java/awt/Cursor.java @@ -133,11 +133,14 @@ public class Cursor implements java.io.Serializable * type. * * @param type The cursor type. + * + * @exception IllegalArgumentException If the specified cursor type is invalid */ public Cursor(int type) { if (type < 0 || type >= PREDEFINED_COUNT) throw new IllegalArgumentException ("invalid cursor " + type); + this.type = type; // FIXME: lookup and set name? } @@ -171,9 +174,20 @@ public class Cursor implements java.io.Serializable return predefined[type]; } + /** + * Retrieves the system specific custom Cursor named Cursor names are, + * for example: "Invalid.16x16". + * + * @exception AWTException + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. + */ public static Cursor getSystemCustomCursor(String name) throws AWTException { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); + // FIXME return null; } diff --git a/java/awt/EventQueue.java b/java/awt/EventQueue.java index 1ce3d1631..6b64fb7ee 100644 --- a/java/awt/EventQueue.java +++ b/java/awt/EventQueue.java @@ -151,6 +151,8 @@ public class EventQueue * Posts a new event to the queue. * * @param event The event to post to the queue. + * + * @exception NullPointerException If event is null. */ public synchronized void postEvent(AWTEvent evt) { @@ -209,7 +211,19 @@ public class EventQueue notify(); } - /** @since JDK1.2 */ + /** + * Causes runnable to have its run method called in the dispatch thread of the + * EventQueue. This will happen after all pending events are processed. The + * call blocks until this has happened. This method will throw an Error if + * called from the event dispatcher thread. + * + * @exception InterruptedException If another thread has interrupted + * this thread. + * @exception InvocationTargetException If an exception is thrown when running + * runnable. + * + * @since 1.2 + */ public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException { @@ -254,6 +268,8 @@ public class EventQueue * All pending events are transferred to the new queue. Calls to postEvent, * getNextEvent, and peekEvent are forwarded to the pushed queue until it * is removed with a pop(). + * + * @exception NullPointerException if newEventQueue is null. */ public synchronized void push(EventQueue newEventQueue) { @@ -271,7 +287,11 @@ public class EventQueue } /** Transfer any pending events from this queue back to the parent queue that - * was previously push()ed. Event dispatch from this queue is suspended. */ + * was previously push()ed. Event dispatch from this queue is suspended. + * + * @exception EmptyStackException If no previous push was made on this + * EventQueue. + */ protected void pop() throws EmptyStackException { if (prev == null) @@ -297,6 +317,12 @@ public class EventQueue } } + /** + * Dispatches an event. The manner in which the event is dispatched depends + * upon the type of the event and the type of the event's source object. + * + * @exception NullPointerException If event is null. + */ protected void dispatchEvent(AWTEvent evt) { if (evt instanceof ActiveEvent) diff --git a/java/awt/FileDialog.java b/java/awt/FileDialog.java index 2019572d5..764424c82 100644 --- a/java/awt/FileDialog.java +++ b/java/awt/FileDialog.java @@ -142,16 +142,15 @@ FileDialog(Frame parent, String title) * @param title The title for this dialog. * @param mode The mode of the dialog, either <code>LOAD</code> or * <code>SAVE</code>. + * + * @exception IllegalArgumentException If an illegal file dialog mode + * is supplied. */ public FileDialog(Frame parent, String title, int mode) { super(parent, title, true); - - if ((mode != LOAD) && (mode != SAVE)) - throw new IllegalArgumentException("Bad mode: " + mode); - - this.mode = mode; + setMode (mode); } /*************************************************************************/ @@ -180,6 +179,9 @@ getMode() * peer is created. * * @param mode The new mode of this file dialog. + * + * @exception IllegalArgumentException If an illegal file dialog mode + * is supplied. */ public void setMode(int mode) diff --git a/java/awt/Label.java b/java/awt/Label.java index 36ea45b94..b029b2a3c 100644 --- a/java/awt/Label.java +++ b/java/awt/Label.java @@ -99,6 +99,8 @@ private String text; /** * Initializes a new instance of <code>Label</code> with no text. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Label() @@ -113,6 +115,8 @@ Label() * text that is aligned to the left. * * @param text The text of the label. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Label(String text) @@ -130,12 +134,17 @@ Label(String text) * @param alignment The desired alignment for the text in this label, * which must be one of <code>LEFT</code>, <code>CENTER</code>, or * <code>RIGHT</code>. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Label(String text, int alignment) { setAlignment (alignment); setText (text); + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/List.java b/java/awt/List.java index f2c6d0788..07fea67b0 100644 --- a/java/awt/List.java +++ b/java/awt/List.java @@ -113,6 +113,8 @@ private ActionListener action_listeners; /** * Initializes a new instance of <code>List</code> with no visible lines * and multi-select disabled. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public List() @@ -127,6 +129,8 @@ List() * number of visible lines and multi-select disabled. * * @param lines The number of visible lines in the list. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public List(int rows) @@ -143,12 +147,17 @@ List(int rows) * @param lines The number of visible lines in the list. * @param multipleMode <code>true</code> if multiple lines can be selected * simultaneously, <code>false</code> otherwise. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public List(int rows, boolean multipleMode) { this.rows = rows; this.multipleMode = multipleMode; + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/Menu.java b/java/awt/Menu.java index 18d63be74..326101b76 100644 --- a/java/awt/Menu.java +++ b/java/awt/Menu.java @@ -95,6 +95,8 @@ static final MenuItem separator = new MenuItem("-"); /** * Initializes a new instance of <code>Menu</code> with no label and that * is not a tearoff; + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Menu() @@ -108,6 +110,8 @@ Menu() * that has the specified label. * * @param label The menu label. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Menu(String label) @@ -124,6 +128,8 @@ Menu(String label) * @param label The label for this menu * @param isTearOff <code>true</code> if this menu is a tear off menu, * <code>false</code> otherwise. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public Menu(String label, boolean isTearOff) @@ -134,6 +140,9 @@ Menu(String label, boolean isTearOff) if (label.equals("Help")) isHelpMenu = true; + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/MenuBar.java b/java/awt/MenuBar.java index 2e1a96361..b9ddef9aa 100644 --- a/java/awt/MenuBar.java +++ b/java/awt/MenuBar.java @@ -86,10 +86,14 @@ private Vector menus = new Vector(); /** * Initializes a new instance of <code>MenuBar</code>. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public MenuBar() { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/MenuComponent.java b/java/awt/MenuComponent.java index b9c6ea020..548aa7793 100644 --- a/java/awt/MenuComponent.java +++ b/java/awt/MenuComponent.java @@ -92,10 +92,14 @@ private static transient Toolkit toolkit = Toolkit.getDefaultToolkit(); /** * Default constructor for subclasses. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ protected MenuComponent() { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/PopupMenu.java b/java/awt/PopupMenu.java index 9553b87f1..d0f198047 100644 --- a/java/awt/PopupMenu.java +++ b/java/awt/PopupMenu.java @@ -65,6 +65,9 @@ private static final long serialVersionUID = -4620452533522760060L; /** * Initializes a new instance of <code>PopupMenu</code>. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. */ public PopupMenu() @@ -78,11 +81,17 @@ PopupMenu() * label. * * @param label The label for this popup menu. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() + * returns true. */ public PopupMenu(String label) { super(label); + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java index e558d0bc2..0c9354b28 100644 --- a/java/awt/ScrollPane.java +++ b/java/awt/ScrollPane.java @@ -113,6 +113,8 @@ private Point scrollPosition = new Point(0, 0); /** * Initializes a new instance of <code>ScrollPane</code> with a default * scrollbar policy of <code>SCROLLBARS_AS_NEEDED</code>. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public ScrollPane() @@ -128,10 +130,15 @@ ScrollPane() * * @param scrollbarDisplayPolicy When to display scrollbars, which must * be one of the constants defined in this class. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ public ScrollPane(int scrollbarDisplayPolicy) { + if (GraphicsEnvironment.isHeadless ()) + throw new HeadlessException (); + this.scrollbarDisplayPolicy = scrollbarDisplayPolicy; if (scrollbarDisplayPolicy != SCROLLBARS_ALWAYS diff --git a/java/awt/Scrollbar.java b/java/awt/Scrollbar.java index 1f1875955..b716fa094 100644 --- a/java/awt/Scrollbar.java +++ b/java/awt/Scrollbar.java @@ -40,7 +40,6 @@ package java.awt; import java.awt.peer.ScrollbarPeer; import java.awt.peer.ComponentPeer; - import java.awt.event.AdjustmentListener; import java.awt.event.AdjustmentEvent; @@ -127,6 +126,8 @@ private AdjustmentListener adjustment_listeners; /** * Initializes a new instance of <code>Scrollbar</code> with a * veritical orientation and default values for all other parameters. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public Scrollbar() @@ -145,6 +146,7 @@ Scrollbar() * * @param orientation The orientation of this scrollbar. * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, * @exception IllegalArgumentException If the orientation value is not valid. */ public @@ -168,12 +170,16 @@ Scrollbar(int orientation) throws IllegalArgumentException * @param minimum The minimum value of the scrollbar. * @param maximum The maximum value of the scrollbar. * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, * @exception IllegalArgumentException If the orientation value is not valid. */ public Scrollbar(int orientation, int value, int visibleAmount, int minimum, int maximum) throws IllegalArgumentException { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); + if ((orientation != HORIZONTAL) && (orientation != VERTICAL)) throw new IllegalArgumentException("Bad orientation value: " + orientation); diff --git a/java/awt/TextArea.java b/java/awt/TextArea.java index 799656ec5..f164add49 100644 --- a/java/awt/TextArea.java +++ b/java/awt/TextArea.java @@ -109,6 +109,8 @@ private int scrollbarVisibility; * Initialize a new instance of <code>TextArea</code> that is empty * and is one row and one column. Both horizontal and vertical * scrollbars will be used. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextArea() @@ -124,6 +126,8 @@ TextArea() * scrollbars will be used. * * @param text The text to display in this text area. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextArea(String text) @@ -140,6 +144,8 @@ TextArea(String text) * * @param rows The number of rows in this text area. * @param columns The number of columns in this text area. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextArea(int rows, int columns) @@ -156,6 +162,8 @@ TextArea(int rows, int columns) * @param text The text to display in this text area. * @param rows The number of rows in this text area. * @param columns The number of columns in this text area. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextArea(String text, int rows, int columns) @@ -174,12 +182,17 @@ TextArea(String text, int rows, int columns) * @param rows The number of rows in this text area. * @param columns The number of columns in this text area. * @param scrollbarVisibility Which scrollbars to display. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextArea(String text, int rows, int columns, int scrollbarVisibility) { super(text); + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); + if ((rows < 1) || (columns < 0)) throw new IllegalArgumentException("Bad row or column value"); diff --git a/java/awt/TextField.java b/java/awt/TextField.java index 28d444ce9..0106d77e3 100644 --- a/java/awt/TextField.java +++ b/java/awt/TextField.java @@ -84,9 +84,11 @@ private ActionListener action_listeners; * Constructors */ -/* +/** * Initializes a new instance of <code>TextField</code> that is empty * and has one column. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextField() @@ -102,6 +104,8 @@ TextField() * length of the text string. * * @param text The text to display in the field. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextField(String text) @@ -116,6 +120,8 @@ TextField(String text) * and has the specified number of columns. * * @param columns The number of columns in the text field. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextField(int columns) @@ -131,12 +137,17 @@ TextField(int columns) * * @param text The text to display in the field. * @param columns The number of columns in the field. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true, */ public TextField(String text, int columns) { super(text); this.columns = columns; + + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } /*************************************************************************/ diff --git a/java/awt/Transparency.java b/java/awt/Transparency.java index fc01f5839..fefe6d307 100644 --- a/java/awt/Transparency.java +++ b/java/awt/Transparency.java @@ -47,16 +47,16 @@ package java.awt; public interface Transparency { /** Image data which is completely opaque, for an alpha value of 1.0. */ - int OPAQUE = 1; + static final int OPAQUE = 1; /** * Image data which is either completely opaque or transparent, for an * exact integer alpha value. */ - int BITMASK = 2; + static final int BITMASK = 2; /** Image data which is translucent, for a non-integer alpha value. */ - int TRANSLUCENT = 3; + static final int TRANSLUCENT = 3; /** * Return the transparency type. diff --git a/java/awt/color/CMMException.java b/java/awt/color/CMMException.java index 0d146e6c6..a0948ef27 100644 --- a/java/awt/color/CMMException.java +++ b/java/awt/color/CMMException.java @@ -44,7 +44,7 @@ package java.awt.color; * @author Eric Blake <ebb9@email.byu.edu> * @status updated to 1.4 */ -public class CMMException extends Exception +public class CMMException extends RuntimeException { /** * Compatible with JDK 1.2+. diff --git a/java/awt/color/ColorSpace.java b/java/awt/color/ColorSpace.java index 4f68fabcb..9be70cb38 100644 --- a/java/awt/color/ColorSpace.java +++ b/java/awt/color/ColorSpace.java @@ -46,7 +46,7 @@ import java.io.Serializable; * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @since 1.2 */ -public abstract class ColorSpace +public abstract class ColorSpace implements Serializable { /** * Compatible with JDK 1.2+. diff --git a/java/awt/color/ICC_Profile.java b/java/awt/color/ICC_Profile.java index 7adaac064..eb534ebff 100644 --- a/java/awt/color/ICC_Profile.java +++ b/java/awt/color/ICC_Profile.java @@ -245,7 +245,7 @@ public class ICC_Profile implements Serializable write(new FileOutputStream(filename)); } - public void write(OutputStream out) + public void write(OutputStream out) throws IOException { throw new Error("not implemented"); } diff --git a/java/awt/color/ProfileDataException.java b/java/awt/color/ProfileDataException.java index 130781faf..89f47a207 100644 --- a/java/awt/color/ProfileDataException.java +++ b/java/awt/color/ProfileDataException.java @@ -45,7 +45,7 @@ package java.awt.color; * @author Eric Blake <ebb9@email.byu.edu> * @status updated to 1.4 */ -public class ProfileDataException extends Exception +public class ProfileDataException extends RuntimeException { /** * Compatible with JDK 1.2+. diff --git a/java/awt/datatransfer/Clipboard.java b/java/awt/datatransfer/Clipboard.java index 6ef9e70b6..93bba7c1a 100644 --- a/java/awt/datatransfer/Clipboard.java +++ b/java/awt/datatransfer/Clipboard.java @@ -103,6 +103,8 @@ getName() * Returns the contents of the clipboard. * * @param requestor The object requesting the contents. + * + * @exception IllegalStateException If the clipboard is currently unavailable */ public synchronized Transferable getContents(Object requestor) @@ -120,6 +122,8 @@ getContents(Object requestor) * * @param contents The new clipboard contents. * @param owner The new clipboard owner + * + * @exception IllegalStateException If the clipboard is currently unavailable */ public synchronized void setContents(Transferable contents, ClipboardOwner owner) diff --git a/java/awt/datatransfer/DataFlavor.java b/java/awt/datatransfer/DataFlavor.java index 85f6ae5d4..e1500a792 100644 --- a/java/awt/datatransfer/DataFlavor.java +++ b/java/awt/datatransfer/DataFlavor.java @@ -281,6 +281,7 @@ DataFlavor(Class representationClass, String humanPresentableName) * * @exception IllegalArgumentException If the representation class * specified cannot be loaded. + * @exception ClassNotFoundException If the class is not loaded. */ public DataFlavor(String mimeType, String humanPresentableName, @@ -504,6 +505,8 @@ setHumanPresentableName(String humanPresentableName) * * @return <code>true</code> if the MIME type is equal to this object's * MIME type, <code>false</code> otherwise. + * + * @exception NullPointerException If mimeType is null. */ public final boolean isMimeTypeEqual(String mimeType) @@ -652,6 +655,10 @@ isFlavorJavaFileListType() * Returns a copy of this object. * * @return A copy of this object. + * + * @exception CloneNotSupportedException If the object's class does not support + * the Cloneable interface. Subclasses that override the clone method can also + * throw this exception to indicate that an instance cannot be cloned. */ public Object clone() @@ -813,6 +820,8 @@ normalizeMimeType(String type) * Serialize this class. * * @param stream The <code>ObjectOutput</code> stream to serialize to. + * + * @exception IOException If an error occurs. */ public void writeExternal(ObjectOutput stream) throws IOException @@ -826,6 +835,10 @@ writeExternal(ObjectOutput stream) throws IOException * De-serialize this class. * * @param stream The <code>ObjectInput</code> stream to deserialize from. + * + * @exception IOException If an error ocurs. + * @exception ClassNotFoundException If the class for an object being restored + * cannot be found. */ public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException @@ -950,6 +963,10 @@ selectBestTextFlavor(DataFlavor[] availableFlavors) * * @param transferable The <code>Transferable</code> for which a text * <code>Reader</code> is requested. + * + * @exception IllegalArgumentException If the representation class is not one + * of the seven listed above or the Transferable has null data. + * @exception NullPointerException If the Transferable is null. * @exception UnsupportedFlavorException when the transferable doesn't * support this <code>DataFlavor</code>. Or if the representable class * isn't a (subclass of) <code>Reader</code>, <code>String</code>, diff --git a/java/awt/datatransfer/FlavorMap.java b/java/awt/datatransfer/FlavorMap.java index 96b160842..a39261506 100644 --- a/java/awt/datatransfer/FlavorMap.java +++ b/java/awt/datatransfer/FlavorMap.java @@ -41,42 +41,35 @@ package java.awt.datatransfer; import java.util.Map; /** - * This interface maps between native platform type names and DataFlavors. - * - * @author Aaron M. Renn (arenn@urbanophile.com) - */ + * This interface maps between native platform type names and DataFlavors. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ public interface FlavorMap { + /** + * Maps the specified <code>DataFlavor</code> objects to the native + * data type name. The returned <code>Map</code> has keys that are + * the data flavors and values that are strings. The returned map + * may be modified. This can be useful for implementing nested mappings. + * + * @param flavors An array of data flavors to map + * or null for all data flavors. + * + * @return A <code>Map</code> of native data types. + */ + public abstract Map getNativesForFlavors (DataFlavor[] flavors); -/** - * Maps the specified <code>DataFlavor</code> objects to the native - * data type name. The returned <code>Map</code> has keys that are - * the data flavors and values that are strings. The returned map - * may be modified. This can be useful for implementing nested mappings. - * - * @param flavors An array of data flavors to map - * or null for all data flavors. - * - * @return A <code>Map</code> of native data types. - */ -public abstract Map -getNativesForFlavors(DataFlavor[] flavors); - -/*************************************************************************/ - -/** - * Maps the specified native type names to <code>DataFlavor</code>'s. - * The returned <code>Map</code> has keys that are strings and values - * that are <code>DataFlavor</code>'s. The returned map may be - * modified. This can be useful for implementing nested mappings. - * - * @param natives An array of native types to map - * or null for all native types. - * - * @return A <code>Map</code> of data flavors. - */ -public abstract Map -getFlavorsForNatives(String[] natives); - -} // interface FlavorMap - + /** + * Maps the specified native type names to <code>DataFlavor</code>'s. + * The returned <code>Map</code> has keys that are strings and values + * that are <code>DataFlavor</code>'s. The returned map may be + * modified. This can be useful for implementing nested mappings. + * + * @param natives An array of native types to map + * or null for all native types. + * + * @return A <code>Map</code> of data flavors. + */ + public abstract Map getFlavorsForNatives (String[] natives); +} diff --git a/java/awt/datatransfer/SystemFlavorMap.java b/java/awt/datatransfer/SystemFlavorMap.java index 50064db4c..7d914120e 100644 --- a/java/awt/datatransfer/SystemFlavorMap.java +++ b/java/awt/datatransfer/SystemFlavorMap.java @@ -40,6 +40,7 @@ package java.awt.datatransfer; import java.util.HashMap; import java.util.Map; +import java.util.List; /** * This class maps between native platform type names and DataFlavors. @@ -47,134 +48,122 @@ import java.util.Map; * XXX - The current implementation does no mapping at all. * * @author Mark Wielaard (mark@klomp.org) - */ -public final class SystemFlavorMap implements FlavorMap -{ - -/** - * The default (instance) flavor map. - */ -private static FlavorMap defaultFlavorMap; - -/** - * Private constructor. - */ -private SystemFlavorMap() -{ -} - -/*************************************************************************/ - -/** - * Maps the specified <code>DataFlavor</code> objects to the native - * data type name. The returned <code>Map</code> has keys that are - * the data flavors and values that are strings. The returned map - * may be modified. This can be useful for implementing nested mappings. - * - * @param flavors An array of data flavors to map - * or null for all data flavors. * - * @return A <code>Map</code> of native data types to data flavors. - */ -public Map -getNativesForFlavors(DataFlavor[] flavors) -{ - return(new HashMap()); -} - -/*************************************************************************/ - -/** - * Maps the specified native type names to <code>DataFlavor</code>'s. - * The returned <code>Map</code> has keys that are strings and values - * that are <code>DataFlavor</code>'s. The returned map may be - * modified. This can be useful for implementing nested mappings. - * - * @param natives An array of native types to map - * or null for all native types. - * - * @return A <code>Map</code> of data flavors to native type names. - */ -public Map -getFlavorsForNatives(String[] natives) -{ - return(new HashMap()); -} - -/*************************************************************************/ - -/** - * Returns the default (instance) (System)FlavorMap. - */ -public static FlavorMap -getDefaultFlavorMap() -{ - if (defaultFlavorMap == null) - defaultFlavorMap = new SystemFlavorMap(); - - return(defaultFlavorMap); -} - -/*************************************************************************/ - -/** - * Returns the native type name for the given java mime type. - */ -public static String -encodeJavaMIMEType(String mime) -{ - return null; -} - -/*************************************************************************/ - -/** - * Returns the native type name for the given data flavor. - */ -public static String -encodeDataFlavor(DataFlavor df) -{ - return null; -} - -/*************************************************************************/ - -/** - * Returns true if the native type name can be represented as - * a java mime type. - */ -public static boolean -isJavaMIMEType(String name) -{ - return(false); -} - -/*************************************************************************/ - -/** - * Returns the java mime type for the given the native type name. + * @since 1.2 */ -public static String -decodeJavaMIMEType(String name) +public final class SystemFlavorMap implements FlavorMap, FlavorTable { - return null; -} - -/*************************************************************************/ - -/** - * Returns the data flavor given the native type name - * or null when no such data flavor exists. - */ -public static DataFlavor -decodeDataFlavor(String name) throws ClassNotFoundException -{ - String javaMIMEType = decodeJavaMIMEType(name); - if (javaMIMEType != null) - return(new DataFlavor(javaMIMEType)); - else - return(null); -} + /** + * The default (instance) flavor map. + */ + private static FlavorMap defaultFlavorMap; + + /** + * Private constructor. + */ + private SystemFlavorMap () + { + } + + /** + * Maps the specified <code>DataFlavor</code> objects to the native + * data type name. The returned <code>Map</code> has keys that are + * the data flavors and values that are strings. The returned map + * may be modified. This can be useful for implementing nested mappings. + * + * @param flavors An array of data flavors to map + * or null for all data flavors. + * + * @return A <code>Map</code> of native data types to data flavors. + */ + public Map getNativesForFlavors (DataFlavor[] flavors) + { + return new HashMap(); + } + + /** + * Maps the specified native type names to <code>DataFlavor</code>'s. + * The returned <code>Map</code> has keys that are strings and values + * that are <code>DataFlavor</code>'s. The returned map may be + * modified. This can be useful for implementing nested mappings. + * + * @param natives An array of native types to map + * or null for all native types. + * + * @return A <code>Map</code> of data flavors to native type names. + */ + public Map getFlavorsForNatives (String[] natives) + { + return new HashMap(); + } + + /** + * Returns the default (instance) (System)FlavorMap. + */ + public static FlavorMap getDefaultFlavorMap () + { + if (defaultFlavorMap == null) + defaultFlavorMap = new SystemFlavorMap (); + + return defaultFlavorMap; + } + + /** + * Returns the native type name for the given java mime type. + */ + public static String encodeJavaMIMEType (String mime) + { + return null; + } + + /** + * Returns the native type name for the given data flavor. + */ + public static String encodeDataFlavor (DataFlavor df) + { + return null; + } + + /** + * Returns true if the native type name can be represented as + * a java mime type. + */ + public static boolean isJavaMIMEType (String name) + { + return false; + } + + /** + * Returns the java mime type for the given the native type name. + */ + public static String decodeJavaMIMEType (String name) + { + return null; + } + + /** + * Returns the data flavor given the native type name + * or null when no such data flavor exists. + */ + public static DataFlavor decodeDataFlavor (String name) + throws ClassNotFoundException + { + String javaMIMEType = decodeJavaMIMEType (name); + + if (javaMIMEType != null) + return new DataFlavor (javaMIMEType); + else + return null; + } + + public List getFlavorsForNative (String nat) + { + throw new Error ("Not implemented"); + } + + public List getNativesForFlavor (DataFlavor flav) + { + throw new Error ("Not implemented"); + } } // class SystemFlavorMap - diff --git a/java/awt/dnd/DragGestureEvent.java b/java/awt/dnd/DragGestureEvent.java index 84fa1cbb9..3d268820b 100644 --- a/java/awt/dnd/DragGestureEvent.java +++ b/java/awt/dnd/DragGestureEvent.java @@ -113,15 +113,42 @@ public class DragGestureEvent extends EventObject { return null; } + + /** + * Starts the drag given the initial Cursor to display, the Transferable + * object, and the DragSourceListener to use. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(Cursor dragCursor, Transferable trans) { startDrag(dragCursor, null, null, trans, null); } + + /** + * Starts the drag given the initial Cursor to display, the Transferable + * object, and the DragSourceListener to use. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(Cursor dragCursor, Transferable trans, DragSourceListener l) { startDrag(dragCursor, null, null, trans, l); } + + /** + * Starts the drag given the initial Cursor to display, the Transferable + * object, and the DragSourceListener to use. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable trans, DragSourceListener l) { diff --git a/java/awt/dnd/DragGestureRecognizer.java b/java/awt/dnd/DragGestureRecognizer.java index 674e26e8a..cd204b6fe 100644 --- a/java/awt/dnd/DragGestureRecognizer.java +++ b/java/awt/dnd/DragGestureRecognizer.java @@ -130,6 +130,12 @@ public abstract class DragGestureRecognizer implements Serializable throw new Error("not implemented"); } + /** + * Register a new DragGestureListener. + * + * @exception TooManyListenersException If a DragGestureListener has already + * been added. + */ public void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException { diff --git a/java/awt/dnd/DragSource.java b/java/awt/dnd/DragSource.java index 01cae00a3..740235ac8 100644 --- a/java/awt/dnd/DragSource.java +++ b/java/awt/dnd/DragSource.java @@ -40,6 +40,8 @@ package java.awt.dnd; import java.awt.Component; import java.awt.Cursor; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; import java.awt.Image; import java.awt.Point; import java.awt.datatransfer.FlavorMap; @@ -62,10 +64,20 @@ public class DragSource implements Serializable public static final Cursor DefaultMoveNoDrop = null; public static final Cursor DefaultLinkNoDrop = null; + /** + * Initializes the drag source. + * + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. + */ public DragSource() { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException (); } + /** + * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. + */ public static DragSource getDefaultDragSource() { return null; @@ -76,6 +88,13 @@ public class DragSource implements Serializable return false; } + /** + * Start a drag, given the DragGestureEvent that initiated the drag. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable trans, DragSourceListener dsl, @@ -83,6 +102,13 @@ public class DragSource implements Serializable { } + /** + * Start a drag, given the DragGestureEvent that initiated the drag. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable trans, DragSourceListener dsl, FlavorMap map) @@ -90,6 +116,13 @@ public class DragSource implements Serializable startDrag(trigger, dragCursor, null, null, trans, dsl, map); } + /** + * Start a drag, given the DragGestureEvent that initiated the drag. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable trans, DragSourceListener dsl) @@ -97,12 +130,25 @@ public class DragSource implements Serializable startDrag(trigger, dragCursor, dragImage, imageOffset, trans, dsl, null); } + /** + * Start a drag, given the DragGestureEvent that initiated the drag. + * + * @exception InvalidDnDOperationException If the Drag and Drop system is + * unable to initiate a drag operation, or if the user attempts to start + * a drag while an existing drag operation is still executing. + */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable trans, DragSourceListener dsl) { startDrag(trigger, dragCursor, null, null, trans, dsl, null); } + /** + * Creates the DragSourceContext to handle this drag. + * + * @exception IllegalArgumentException FIXME + * @exception NullPointerException If dscp, dgl, dragImage or t is null. + */ protected DragSourceContext createDragSourceContext(DragSourceContextPeer peer, DragGestureEvent dge, Cursor cursor, Image image, Point offset, diff --git a/java/awt/dnd/DropTarget.java b/java/awt/dnd/DropTarget.java index c469605b8..53c09178d 100644 --- a/java/awt/dnd/DropTarget.java +++ b/java/awt/dnd/DropTarget.java @@ -42,10 +42,13 @@ import java.awt.Component; import java.awt.datatransfer.FlavorMap; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.Serializable; +import java.util.EventListener; import java.util.TooManyListenersException; /** STUB CLASS ONLY */ public class DropTarget + implements DropTargetListener, EventListener, Serializable { protected static class DropTargetAutoScroller implements ActionListener @@ -67,6 +70,9 @@ public class DropTarget } } + // FIXME: check the correctness of default value. + private boolean isActive = false; + /** * FIXME * @@ -133,11 +139,12 @@ public class DropTarget public void setActive(boolean isActive) { + this.isActive = isActive; } public boolean isActive() { - return false; + return this.isActive; } /** diff --git a/java/awt/geom/PathIterator.java b/java/awt/geom/PathIterator.java index 6cf77d74d..c23eb3513 100644 --- a/java/awt/geom/PathIterator.java +++ b/java/awt/geom/PathIterator.java @@ -84,7 +84,7 @@ public interface PathIterator * (P1), and final interpolated control point (P2): * <pre> * P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2 - * 0 <= t <= 1 + * 0 <= t <= 1 * B(n,m) = mth coefficient of nth degree Bernstein polynomial * = C(n,m) * t^(m) * (1 - t)^(n-m) * C(n,m) = Combinations of n things, taken m at a time @@ -100,7 +100,7 @@ public interface PathIterator * (P2), and final interpolated control point (P3): * <pre> * P(t) = B(3,0)*CP + B(3,1)*P1 + B(3,2)*P2 + B(3,3)*P3 - * 0 <= t <= 1 + * 0 <= t <= 1 * B(n,m) = mth coefficient of nth degree Bernstein polynomial * = C(n,m) * t^(m) * (1 - t)^(n-m) * C(n,m) = Combinations of n things, taken m at a time |