Commit b6d3cb37 by Thomas Fitzsimmons Committed by Thomas Fitzsimmons

GtkListPeer.java, [...]: Fix handling of alias methods...

2004-02-03  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkListPeer.java,
	java/awt/BorderLayout.java, java/awt/CardLayout.java,
	java/awt/CheckboxGroup.java, java/awt/Choice.java,
	java/awt/Component.java, java/awt/Container.java,
	java/awt/FontMetrics.java, java/awt/GridBagLayout.java,
	java/awt/LayoutManager2.java, java/awt/List.java,
	java/awt/Menu.java, java/awt/MenuBar.java,
	java/awt/MenuItem.java, java/awt/Polygon.java,
	java/awt/Rectangle.java, java/awt/ScrollPane.java,
	java/awt/Scrollbar.java, java/awt/TextArea.java,
	java/awt/TextField.java,
	java/awt/image/renderable/RenderContext.java,
	javax/swing/JApplet.java: Fix handling of alias methods, where a
	method has been deprecated in favour of a new one with the same
	funtion but a different name.  Put the method implementation in
	the deprecated method and have the new method call the
	deprecated one.  Make all other code call the new method.

From-SVN: r77178
parent 5a98fa7b
2004-02-03 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkListPeer.java,
java/awt/BorderLayout.java, java/awt/CardLayout.java,
java/awt/CheckboxGroup.java, java/awt/Choice.java,
java/awt/Component.java, java/awt/Container.java,
java/awt/FontMetrics.java, java/awt/GridBagLayout.java,
java/awt/LayoutManager2.java, java/awt/List.java,
java/awt/Menu.java, java/awt/MenuBar.java,
java/awt/MenuItem.java, java/awt/Polygon.java,
java/awt/Rectangle.java, java/awt/ScrollPane.java,
java/awt/Scrollbar.java, java/awt/TextArea.java,
java/awt/TextField.java,
java/awt/image/renderable/RenderContext.java,
javax/swing/JApplet.java: Fix handling of alias methods, where a
method has been deprecated in favour of a new one with the same
funtion but a different name. Put the method implementation in
the deprecated method and have the new method call the
deprecated one. Make all other code call the new method.
2004-02-03 Mohan Embar <gnustuff@thisiscool.com> 2004-02-03 Mohan Embar <gnustuff@thisiscool.com>
* gnu/java/nio/DatagramChannelImpl.java * gnu/java/nio/DatagramChannelImpl.java
......
...@@ -85,18 +85,12 @@ public class GtkListPeer extends GtkComponentPeer ...@@ -85,18 +85,12 @@ public class GtkListPeer extends GtkComponentPeer
public Dimension getMinimumSize (int rows) public Dimension getMinimumSize (int rows)
{ {
int dims[] = new int[2]; return minimumSize (rows);
getSize (rows, dims);
return (new Dimension (dims[0], dims[1]));
} }
public Dimension getPreferredSize (int rows) public Dimension getPreferredSize (int rows)
{ {
int dims[] = new int[2]; return preferredSize (rows);
getSize (rows, dims);
return (new Dimension (dims[0], dims[1]));
} }
public native int[] getSelectedIndexes (); public native int[] getSelectedIndexes ();
...@@ -104,12 +98,18 @@ public class GtkListPeer extends GtkComponentPeer ...@@ -104,12 +98,18 @@ public class GtkListPeer extends GtkComponentPeer
public Dimension minimumSize (int rows) public Dimension minimumSize (int rows)
{ {
return (getMinimumSize (rows)); int dims[] = new int[2];
getSize (rows, dims);
return new Dimension (dims[0], dims[1]);
} }
public Dimension preferredSize (int rows) public Dimension preferredSize (int rows)
{ {
return (getPreferredSize (rows)); int dims[] = new int[2];
getSize (rows, dims);
return new Dimension (dims[0], dims[1]);
} }
public void removeAll () public void removeAll ()
......
...@@ -349,7 +349,28 @@ addLayoutComponent(Component component, Object constraints) ...@@ -349,7 +349,28 @@ addLayoutComponent(Component component, Object constraints)
if (constraints != null && ! (constraints instanceof String)) if (constraints != null && ! (constraints instanceof String))
throw new IllegalArgumentException("Constraint must be a string"); throw new IllegalArgumentException("Constraint must be a string");
String str = (String)constraints; addLayoutComponent((String) constraints, component);
}
/*************************************************************************/
/**
* Adds a component to the layout in the specified constraint position,
* which must be one of the string constants defined in this class.
*
* @param constraints The constraint string.
* @param component The component to add.
*
* @exception IllegalArgumentException If the constraint object is not
* one of the specified constants in this class.
*
* @deprecated This method is deprecated in favor of
* <code>addLayoutComponent(Component, Object)</code>.
*/
public void
addLayoutComponent(String constraints, Component component)
{
String str = constraints;
if (str == null || str.equals(CENTER)) if (str == null || str.equals(CENTER))
center = component; center = component;
...@@ -376,27 +397,6 @@ addLayoutComponent(Component component, Object constraints) ...@@ -376,27 +397,6 @@ addLayoutComponent(Component component, Object constraints)
/*************************************************************************/ /*************************************************************************/
/** /**
* Adds a component to the layout in the specified constraint position,
* which must be one of the string constants defined in this class.
*
* @param constraints The constraint string.
* @param component The component to add.
*
* @exception IllegalArgumentException If the constraint object is not
* one of the specified constants in this class.
*
* @deprecated This method is deprecated in favor of
* <code>addLayoutComponent(Component, Object)</code>.
*/
public void
addLayoutComponent(String constraints, Component component)
{
addLayoutComponent(component, constraints);
}
/*************************************************************************/
/**
* Removes the specified component from the layout. * Removes the specified component from the layout.
* *
* @param component The component to remove from the layout. * @param component The component to remove from the layout.
......
...@@ -90,7 +90,7 @@ public class CardLayout implements LayoutManager2, Serializable ...@@ -90,7 +90,7 @@ public class CardLayout implements LayoutManager2, Serializable
if (! (constraints instanceof String)) if (! (constraints instanceof String))
throw new IllegalArgumentException ("Object " + constraints throw new IllegalArgumentException ("Object " + constraints
+ " is not a string"); + " is not a string");
tab.put (constraints, comp); addLayoutComponent ((String) constraints, comp);
} }
/** Add a new component to the layout. The name can be used later /** Add a new component to the layout. The name can be used later
...@@ -102,7 +102,7 @@ public class CardLayout implements LayoutManager2, Serializable ...@@ -102,7 +102,7 @@ public class CardLayout implements LayoutManager2, Serializable
*/ */
public void addLayoutComponent (String name, Component comp) public void addLayoutComponent (String name, Component comp)
{ {
addLayoutComponent (comp, name); tab.put (name, comp);
} }
/** Cause the first component in the container to be displayed. /** Cause the first component in the container to be displayed.
......
...@@ -95,8 +95,8 @@ CheckboxGroup() ...@@ -95,8 +95,8 @@ CheckboxGroup()
public Checkbox public Checkbox
getSelectedCheckbox() getSelectedCheckbox()
{ {
return(selectedCheckbox); return getCurrent ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -126,17 +126,7 @@ getCurrent() ...@@ -126,17 +126,7 @@ getCurrent()
public void public void
setSelectedCheckbox(Checkbox selectedCheckbox) setSelectedCheckbox(Checkbox selectedCheckbox)
{ {
if (this.selectedCheckbox != null) setCurrent (selectedCheckbox);
{
if (this.selectedCheckbox.getCheckboxGroup() != this)
return;
this.selectedCheckbox.setState(false);
}
this.selectedCheckbox = selectedCheckbox;
if (selectedCheckbox != null)
selectedCheckbox.setState(true);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -153,7 +143,17 @@ setSelectedCheckbox(Checkbox selectedCheckbox) ...@@ -153,7 +143,17 @@ setSelectedCheckbox(Checkbox selectedCheckbox)
public void public void
setCurrent(Checkbox selectedCheckbox) setCurrent(Checkbox selectedCheckbox)
{ {
setSelectedCheckbox(selectedCheckbox); if (this.selectedCheckbox != null)
{
if (this.selectedCheckbox.getCheckboxGroup() != this)
return;
this.selectedCheckbox.setState(false);
}
this.selectedCheckbox = selectedCheckbox;
if (selectedCheckbox != null)
selectedCheckbox.setState(true);
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -111,7 +111,7 @@ private ItemListener item_listeners; ...@@ -111,7 +111,7 @@ private ItemListener item_listeners;
public int public int
getItemCount() getItemCount()
{ {
return(pItems.size()); return countItems ();
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -779,9 +779,7 @@ public abstract class Component ...@@ -779,9 +779,7 @@ public abstract class Component
*/ */
public void setEnabled(boolean b) public void setEnabled(boolean b)
{ {
this.enabled = b; enable (b);
if (peer != null)
peer.setEnabled(b);
} }
/** /**
...@@ -791,7 +789,9 @@ public abstract class Component ...@@ -791,7 +789,9 @@ public abstract class Component
*/ */
public void enable() public void enable()
{ {
setEnabled(true); this.enabled = true;
if (peer != null)
peer.setEnabled (true);
} }
/** /**
...@@ -802,7 +802,10 @@ public abstract class Component ...@@ -802,7 +802,10 @@ public abstract class Component
*/ */
public void enable(boolean b) public void enable(boolean b)
{ {
setEnabled(b); if (b)
enable ();
else
disable ();
} }
/** /**
...@@ -812,7 +815,9 @@ public abstract class Component ...@@ -812,7 +815,9 @@ public abstract class Component
*/ */
public void disable() public void disable()
{ {
setEnabled(false); this.enabled = false;
if (peer != null)
peer.setEnabled (false);
} }
/** /**
...@@ -856,10 +861,7 @@ public abstract class Component ...@@ -856,10 +861,7 @@ public abstract class Component
// Inspection by subclassing shows that Sun's implementation calls // Inspection by subclassing shows that Sun's implementation calls
// show(boolean) which then calls show() or hide(). It is the show() // show(boolean) which then calls show() or hide(). It is the show()
// method that is overriden in subclasses like Window. // method that is overriden in subclasses like Window.
if (b) show (b);
show();
else
hide();
} }
/** /**
...@@ -887,7 +889,10 @@ public abstract class Component ...@@ -887,7 +889,10 @@ public abstract class Component
*/ */
public void show(boolean b) public void show(boolean b)
{ {
setVisible(b); if (b)
show ();
else
hide ();
} }
/** /**
...@@ -1083,7 +1088,7 @@ public abstract class Component ...@@ -1083,7 +1088,7 @@ public abstract class Component
*/ */
public Point getLocation() public Point getLocation()
{ {
return new Point(x, y); return location ();
} }
/** /**
...@@ -1110,7 +1115,7 @@ public abstract class Component ...@@ -1110,7 +1115,7 @@ public abstract class Component
*/ */
public Point location() public Point location()
{ {
return getLocation(); return new Point (x, y);
} }
/** /**
...@@ -1125,13 +1130,7 @@ public abstract class Component ...@@ -1125,13 +1130,7 @@ public abstract class Component
*/ */
public void setLocation(int x, int y) public void setLocation(int x, int y)
{ {
if (this.x == x && this.y == y) move (x, y);
return;
invalidate();
this.x = x;
this.y = y;
if (peer != null)
peer.setBounds(x, y, width, height);
} }
/** /**
...@@ -1145,7 +1144,13 @@ public abstract class Component ...@@ -1145,7 +1144,13 @@ public abstract class Component
*/ */
public void move(int x, int y) public void move(int x, int y)
{ {
setLocation(x, y); if (this.x == x && this.y == y)
return;
invalidate ();
this.x = x;
this.y = y;
if (peer != null)
peer.setBounds (x, y, width, height);
} }
/** /**
...@@ -1173,7 +1178,7 @@ public abstract class Component ...@@ -1173,7 +1178,7 @@ public abstract class Component
*/ */
public Dimension getSize() public Dimension getSize()
{ {
return new Dimension(width, height); return size ();
} }
/** /**
...@@ -1184,7 +1189,7 @@ public abstract class Component ...@@ -1184,7 +1189,7 @@ public abstract class Component
*/ */
public Dimension size() public Dimension size()
{ {
return getSize(); return new Dimension (width, height);
} }
/** /**
...@@ -1197,13 +1202,7 @@ public abstract class Component ...@@ -1197,13 +1202,7 @@ public abstract class Component
*/ */
public void setSize(int width, int height) public void setSize(int width, int height)
{ {
if (this.width == width && this.height == height) resize (width, height);
return;
invalidate();
this.width = width;
this.height = height;
if (peer != null)
peer.setBounds(x, y, width, height);
} }
/** /**
...@@ -1215,7 +1214,13 @@ public abstract class Component ...@@ -1215,7 +1214,13 @@ public abstract class Component
*/ */
public void resize(int width, int height) public void resize(int width, int height)
{ {
setSize(width, height); if (this.width == width && this.height == height)
return;
invalidate ();
this.width = width;
this.height = height;
if (peer != null)
peer.setBounds (x, y, width, height);
} }
/** /**
...@@ -1229,7 +1234,7 @@ public abstract class Component ...@@ -1229,7 +1234,7 @@ public abstract class Component
*/ */
public void setSize(Dimension d) public void setSize(Dimension d)
{ {
setSize(d.width, d.height); resize (d);
} }
/** /**
...@@ -1241,7 +1246,7 @@ public abstract class Component ...@@ -1241,7 +1246,7 @@ public abstract class Component
*/ */
public void resize(Dimension d) public void resize(Dimension d)
{ {
setSize(d.width, d.height); resize (d.width, d.height);
} }
/** /**
...@@ -1256,7 +1261,7 @@ public abstract class Component ...@@ -1256,7 +1261,7 @@ public abstract class Component
*/ */
public Rectangle getBounds() public Rectangle getBounds()
{ {
return new Rectangle(x, y, width, height); return bounds ();
} }
/** /**
...@@ -1269,7 +1274,7 @@ public abstract class Component ...@@ -1269,7 +1274,7 @@ public abstract class Component
*/ */
public Rectangle bounds() public Rectangle bounds()
{ {
return getBounds(); return new Rectangle (x, y, width, height);
} }
/** /**
...@@ -1289,15 +1294,7 @@ public abstract class Component ...@@ -1289,15 +1294,7 @@ public abstract class Component
*/ */
public void setBounds(int x, int y, int w, int h) public void setBounds(int x, int y, int w, int h)
{ {
if (this.x == x && this.y == y && width == w && height == h) reshape (x, y, w, h);
return;
invalidate();
this.x = x;
this.y = y;
width = w;
height = h;
if (peer != null)
peer.setBounds(x, y, w, h);
} }
/** /**
...@@ -1306,13 +1303,22 @@ public abstract class Component ...@@ -1306,13 +1303,22 @@ public abstract class Component
* *
* @param x the X coordinate of the upper left corner of the rectangle * @param x the X coordinate of the upper left corner of the rectangle
* @param y the Y coordinate of the upper left corner of the rectangle * @param y the Y coordinate of the upper left corner of the rectangle
* @param w the width of the rectangle * @param width the width of the rectangle
* @param h the height of the rectangle * @param height the height of the rectangle
* @deprecated use {@link #setBounds(int, int, int, int)} instead * @deprecated use {@link #setBounds(int, int, int, int)} instead
*/ */
public void reshape(int x, int y, int width, int height) public void reshape(int x, int y, int width, int height)
{ {
setBounds(x, y, width, height); if (this.x == x && this.y == y
&& this.width == width && this.height == height)
return;
invalidate ();
this.x = x;
this.y = y;
this.width = width;
this.height = height;
if (peer != null)
peer.setBounds (x, y, width, height);
} }
/** /**
...@@ -1329,7 +1335,7 @@ public abstract class Component ...@@ -1329,7 +1335,7 @@ public abstract class Component
*/ */
public void setBounds(Rectangle r) public void setBounds(Rectangle r)
{ {
setBounds(r.x, r.y, r.width, r.height); setBounds (r.x, r.y, r.width, r.height);
} }
/** /**
...@@ -1560,7 +1566,7 @@ public abstract class Component ...@@ -1560,7 +1566,7 @@ public abstract class Component
*/ */
public void doLayout() public void doLayout()
{ {
// nothing to do unless we're a container layout ();
} }
/** /**
...@@ -1571,7 +1577,7 @@ public abstract class Component ...@@ -1571,7 +1577,7 @@ public abstract class Component
*/ */
public void layout() public void layout()
{ {
doLayout(); // Nothing to do unless we're a container.
} }
/** /**
...@@ -2076,7 +2082,7 @@ public abstract class Component ...@@ -2076,7 +2082,7 @@ public abstract class Component
*/ */
public boolean contains(int x, int y) public boolean contains(int x, int y)
{ {
return x >= 0 && y >= 0 && x < width && y < height; return inside (x, y);
} }
/** /**
...@@ -2090,7 +2096,7 @@ public abstract class Component ...@@ -2090,7 +2096,7 @@ public abstract class Component
*/ */
public boolean inside(int x, int y) public boolean inside(int x, int y)
{ {
return contains(x, y); return x >= 0 && y >= 0 && x < width && y < height;
} }
/** /**
...@@ -2105,7 +2111,7 @@ public abstract class Component ...@@ -2105,7 +2111,7 @@ public abstract class Component
*/ */
public boolean contains(Point p) public boolean contains(Point p)
{ {
return contains(p.x, p.y); return contains (p.x, p.y);
} }
/** /**
...@@ -2120,7 +2126,7 @@ public abstract class Component ...@@ -2120,7 +2126,7 @@ public abstract class Component
*/ */
public Component getComponentAt(int x, int y) public Component getComponentAt(int x, int y)
{ {
return contains(x, y) ? this : null; return locate (x, y);
} }
/** /**
...@@ -2135,7 +2141,7 @@ public abstract class Component ...@@ -2135,7 +2141,7 @@ public abstract class Component
*/ */
public Component locate(int x, int y) public Component locate(int x, int y)
{ {
return getComponentAt(x, y); return contains (x, y) ? this : null;
} }
/** /**
...@@ -2151,7 +2157,7 @@ public abstract class Component ...@@ -2151,7 +2157,7 @@ public abstract class Component
*/ */
public Component getComponentAt(Point p) public Component getComponentAt(Point p)
{ {
return getComponentAt(p.x, p.y); return getComponentAt (p.x, p.y);
} }
/** /**
......
...@@ -106,7 +106,7 @@ public class Container extends Component ...@@ -106,7 +106,7 @@ public class Container extends Component
*/ */
public int getComponentCount() public int getComponentCount()
{ {
return ncomponents; return countComponents ();
} }
/** /**
...@@ -118,7 +118,7 @@ public class Container extends Component ...@@ -118,7 +118,7 @@ public class Container extends Component
*/ */
public int countComponents() public int countComponents()
{ {
return getComponentCount(); return ncomponents;
} }
/** /**
...@@ -186,10 +186,7 @@ public class Container extends Component ...@@ -186,10 +186,7 @@ public class Container extends Component
*/ */
public Insets getInsets() public Insets getInsets()
{ {
if (peer == null) return insets ();
return new Insets(0, 0, 0, 0);
return ((ContainerPeer) peer).getInsets();
} }
/** /**
...@@ -201,7 +198,10 @@ public class Container extends Component ...@@ -201,7 +198,10 @@ public class Container extends Component
*/ */
public Insets insets() public Insets insets()
{ {
return getInsets(); if (peer == null)
return new Insets (0, 0, 0, 0);
return ((ContainerPeer) peer).getInsets ();
} }
/** /**
...@@ -463,8 +463,7 @@ public class Container extends Component ...@@ -463,8 +463,7 @@ public class Container extends Component
*/ */
public void doLayout() public void doLayout()
{ {
if (layoutMgr != null) layout ();
layoutMgr.layoutContainer(this);
} }
/** /**
...@@ -474,7 +473,8 @@ public class Container extends Component ...@@ -474,7 +473,8 @@ public class Container extends Component
*/ */
public void layout() public void layout()
{ {
doLayout(); if (layoutMgr != null)
layoutMgr.layoutContainer (this);
} }
/** /**
...@@ -555,7 +555,7 @@ public class Container extends Component ...@@ -555,7 +555,7 @@ public class Container extends Component
*/ */
public Dimension getPreferredSize() public Dimension getPreferredSize()
{ {
return preferredSize(); return preferredSize ();
} }
/** /**
...@@ -567,10 +567,10 @@ public class Container extends Component ...@@ -567,10 +567,10 @@ public class Container extends Component
*/ */
public Dimension preferredSize() public Dimension preferredSize()
{ {
if (layoutMgr != null) if (layoutMgr != null)
return layoutMgr.preferredLayoutSize(this); return layoutMgr.preferredLayoutSize (this);
else else
return super.preferredSize(); return super.preferredSize ();
} }
/** /**
...@@ -580,7 +580,7 @@ public class Container extends Component ...@@ -580,7 +580,7 @@ public class Container extends Component
*/ */
public Dimension getMinimumSize() public Dimension getMinimumSize()
{ {
return minimumSize(); return minimumSize ();
} }
/** /**
...@@ -592,10 +592,10 @@ public class Container extends Component ...@@ -592,10 +592,10 @@ public class Container extends Component
*/ */
public Dimension minimumSize() public Dimension minimumSize()
{ {
if (layoutMgr != null) if (layoutMgr != null)
return layoutMgr.minimumLayoutSize(this); return layoutMgr.minimumLayoutSize (this);
else else
return super.minimumSize(); return super.minimumSize ();
} }
/** /**
...@@ -833,23 +833,7 @@ public class Container extends Component ...@@ -833,23 +833,7 @@ public class Container extends Component
*/ */
public Component getComponentAt(int x, int y) public Component getComponentAt(int x, int y)
{ {
synchronized (getTreeLock ()) return locate (x, y);
{
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;
}
} }
/** /**
...@@ -869,7 +853,23 @@ public class Container extends Component ...@@ -869,7 +853,23 @@ public class Container extends Component
*/ */
public Component locate(int x, int y) public Component locate(int x, int y)
{ {
return getComponentAt(x, y); 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;
}
} }
/** /**
...@@ -886,7 +886,7 @@ public class Container extends Component ...@@ -886,7 +886,7 @@ public class Container extends Component
*/ */
public Component getComponentAt(Point p) public Component getComponentAt(Point p)
{ {
return getComponentAt(p.x, p.y); return getComponentAt (p.x, p.y);
} }
public Component findComponentAt(int x, int y) public Component findComponentAt(int x, int y)
......
...@@ -195,7 +195,7 @@ getMaxAscent() ...@@ -195,7 +195,7 @@ getMaxAscent()
public int public int
getMaxDescent() getMaxDescent()
{ {
return(getDescent()); return getMaxDecent ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -212,7 +212,7 @@ getMaxDescent() ...@@ -212,7 +212,7 @@ getMaxDescent()
public int public int
getMaxDecent() getMaxDecent()
{ {
return(getMaxDescent()); return getDescent ();
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -52,12 +52,12 @@ public interface LayoutManager2 extends LayoutManager ...@@ -52,12 +52,12 @@ public interface LayoutManager2 extends LayoutManager
{ {
/** /**
* Adds the specified component to the layout, with the specified * Adds the specified component to the layout, with the specified
* constraint object. * constraints object.
* *
* @param component the component to add * @param component the component to add
* @param constraint the constraint to satisfy * @param constraints the constraints to satisfy
*/ */
void addLayoutComponent(Component component, Object contraint); void addLayoutComponent(Component component, Object contraints);
/** /**
* Determines the maximum size of the specified target container. * Determines the maximum size of the specified target container.
......
...@@ -175,7 +175,7 @@ List(int rows, boolean multipleMode) ...@@ -175,7 +175,7 @@ List(int rows, boolean multipleMode)
public int public int
getItemCount() getItemCount()
{ {
return(items.size()); return countItems ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -191,7 +191,7 @@ getItemCount() ...@@ -191,7 +191,7 @@ getItemCount()
public int public int
countItems() countItems()
{ {
return(getItemCount()); return items.size ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -249,7 +249,7 @@ getRows() ...@@ -249,7 +249,7 @@ getRows()
public boolean public boolean
isMultipleMode() isMultipleMode()
{ {
return(multipleMode); return allowsMultipleSelections ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -266,7 +266,7 @@ isMultipleMode() ...@@ -266,7 +266,7 @@ isMultipleMode()
public boolean public boolean
allowsMultipleSelections() allowsMultipleSelections()
{ {
return(multipleMode); return multipleMode;
} }
/*************************************************************************/ /*************************************************************************/
...@@ -281,12 +281,7 @@ allowsMultipleSelections() ...@@ -281,12 +281,7 @@ allowsMultipleSelections()
public void public void
setMultipleMode(boolean multipleMode) setMultipleMode(boolean multipleMode)
{ {
this.multipleMode = multipleMode; setMultipleSelections (multipleMode);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.setMultipleMode (multipleMode);
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -303,7 +298,11 @@ setMultipleMode(boolean multipleMode) ...@@ -303,7 +298,11 @@ setMultipleMode(boolean multipleMode)
public void public void
setMultipleSelections(boolean multipleMode) setMultipleSelections(boolean multipleMode)
{ {
setMultipleMode(multipleMode); this.multipleMode = multipleMode;
ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
peer.setMultipleMode (multipleMode);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -316,7 +315,7 @@ setMultipleSelections(boolean multipleMode) ...@@ -316,7 +315,7 @@ setMultipleSelections(boolean multipleMode)
public Dimension public Dimension
getMinimumSize() getMinimumSize()
{ {
return(getMinimumSize(rows)); return getMinimumSize (getRows ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -332,7 +331,7 @@ getMinimumSize() ...@@ -332,7 +331,7 @@ getMinimumSize()
public Dimension public Dimension
minimumSize() minimumSize()
{ {
return(getMinimumSize(rows)); return minimumSize (getRows ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -348,11 +347,7 @@ minimumSize() ...@@ -348,11 +347,7 @@ minimumSize()
public Dimension public Dimension
getMinimumSize(int rows) getMinimumSize(int rows)
{ {
ListPeer lp = (ListPeer)getPeer(); return minimumSize (rows);
if (lp != null)
return(lp.minimumSize(rows));
else
return(new Dimension(0,0));
} }
/*************************************************************************/ /*************************************************************************/
...@@ -371,7 +366,11 @@ getMinimumSize(int rows) ...@@ -371,7 +366,11 @@ getMinimumSize(int rows)
public Dimension public Dimension
minimumSize(int rows) minimumSize(int rows)
{ {
return(getMinimumSize(rows)); ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
return peer.minimumSize (rows);
else
return new Dimension (0, 0);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -384,7 +383,7 @@ minimumSize(int rows) ...@@ -384,7 +383,7 @@ minimumSize(int rows)
public Dimension public Dimension
getPreferredSize() getPreferredSize()
{ {
return(getPreferredSize(rows)); return getPreferredSize (getRows ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -400,7 +399,7 @@ getPreferredSize() ...@@ -400,7 +399,7 @@ getPreferredSize()
public Dimension public Dimension
preferredSize() preferredSize()
{ {
return(getPreferredSize(rows)); return preferredSize (getRows ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -416,11 +415,7 @@ preferredSize() ...@@ -416,11 +415,7 @@ preferredSize()
public Dimension public Dimension
getPreferredSize(int rows) getPreferredSize(int rows)
{ {
ListPeer lp = (ListPeer)getPeer(); return preferredSize (rows);
if (lp != null)
return(lp.preferredSize(rows));
else
return(new Dimension(0,0));
} }
/*************************************************************************/ /*************************************************************************/
...@@ -439,7 +434,11 @@ getPreferredSize(int rows) ...@@ -439,7 +434,11 @@ getPreferredSize(int rows)
public Dimension public Dimension
preferredSize(int rows) preferredSize(int rows)
{ {
return(getPreferredSize(rows)); ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
return peer.preferredSize (rows);
else
return new Dimension (0, 0);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -452,7 +451,7 @@ preferredSize(int rows) ...@@ -452,7 +451,7 @@ preferredSize(int rows)
public void public void
add(String item) add(String item)
{ {
add(item, -1); add (item, -1);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -467,7 +466,7 @@ add(String item) ...@@ -467,7 +466,7 @@ add(String item)
public void public void
addItem(String item) addItem(String item)
{ {
addItem(item, -1); addItem (item, -1);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -484,16 +483,7 @@ addItem(String item) ...@@ -484,16 +483,7 @@ addItem(String item)
public void public void
add(String item, int index) add(String item, int index)
{ {
if ((index == -1) || (index >= items.size())) addItem (item, index);
items.addElement(item);
else
items.insertElementAt(item, index);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.add (item, index);
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -512,7 +502,14 @@ add(String item, int index) ...@@ -512,7 +502,14 @@ add(String item, int index)
public void public void
addItem(String item, int index) addItem(String item, int index)
{ {
add(item, index); if ((index == -1) || (index >= items.size ()))
items.addElement (item);
else
items.insertElementAt (item, index);
ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
peer.add (item, index);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -529,7 +526,11 @@ addItem(String item, int index) ...@@ -529,7 +526,11 @@ addItem(String item, int index)
public void public void
delItem(int index) throws IllegalArgumentException delItem(int index) throws IllegalArgumentException
{ {
remove(index); items.removeElementAt (index);
ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
peer.delItems (index, index);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -544,12 +545,7 @@ delItem(int index) throws IllegalArgumentException ...@@ -544,12 +545,7 @@ delItem(int index) throws IllegalArgumentException
public void public void
remove(int index) throws IllegalArgumentException remove(int index) throws IllegalArgumentException
{ {
items.removeElementAt (index); delItem (index);
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.delItems (index, index);
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -613,12 +609,7 @@ remove(String item) throws IllegalArgumentException ...@@ -613,12 +609,7 @@ remove(String item) throws IllegalArgumentException
public synchronized void public synchronized void
removeAll() removeAll()
{ {
items.clear(); clear ();
if (peer != null)
{
ListPeer l = (ListPeer) peer;
l.removeAll ();
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -631,7 +622,11 @@ removeAll() ...@@ -631,7 +622,11 @@ removeAll()
public void public void
clear() clear()
{ {
removeAll(); items.clear();
ListPeer peer = (ListPeer) getPeer ();
if (peer != null)
peer.removeAll ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -782,13 +777,7 @@ getSelectedObjects() ...@@ -782,13 +777,7 @@ getSelectedObjects()
public boolean public boolean
isIndexSelected(int index) isIndexSelected(int index)
{ {
int[] indexes = getSelectedIndexes(); return isSelected (index);
for (int i = 0; i < indexes.length; i++)
if (indexes[i] == index)
return(true);
return(false);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -807,7 +796,13 @@ isIndexSelected(int index) ...@@ -807,7 +796,13 @@ isIndexSelected(int index)
public boolean public boolean
isSelected(int index) isSelected(int index)
{ {
return(isIndexSelected(index)); int[] indexes = getSelectedIndexes ();
for (int i = 0; i < indexes.length; i++)
if (indexes[i] == index)
return true;
return false;
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -171,7 +171,7 @@ isTearOff() ...@@ -171,7 +171,7 @@ isTearOff()
public int public int
getItemCount() getItemCount()
{ {
return(items.size()); return countItems ();
} }
/** /**
...@@ -183,7 +183,7 @@ getItemCount() ...@@ -183,7 +183,7 @@ getItemCount()
*/ */
public int countItems () public int countItems ()
{ {
return getItemCount (); return items.size ();
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -219,8 +219,7 @@ remove(MenuComponent menu) ...@@ -219,8 +219,7 @@ remove(MenuComponent menu)
public int public int
getMenuCount() getMenuCount()
{ {
// FIXME: How does the help menu fit in here? return countMenus ();
return(menus.size());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -235,7 +234,8 @@ getMenuCount() ...@@ -235,7 +234,8 @@ getMenuCount()
public int public int
countMenus() countMenus()
{ {
return(getMenuCount()); // FIXME: How does the help menu fit in here?
return menus.size ();
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -202,15 +202,7 @@ isEnabled() ...@@ -202,15 +202,7 @@ isEnabled()
public synchronized void public synchronized void
setEnabled(boolean enabled) setEnabled(boolean enabled)
{ {
if (enabled == this.enabled) enable (enabled);
return;
this.enabled = enabled;
if (peer != null)
{
MenuItemPeer mp = (MenuItemPeer) peer;
mp.setEnabled (enabled);
}
} }
/*************************************************************************/ /*************************************************************************/
...@@ -226,7 +218,10 @@ setEnabled(boolean enabled) ...@@ -226,7 +218,10 @@ setEnabled(boolean enabled)
public void public void
enable(boolean enabled) enable(boolean enabled)
{ {
setEnabled(enabled); if (enabled)
enable ();
else
disable ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -239,7 +234,12 @@ enable(boolean enabled) ...@@ -239,7 +234,12 @@ enable(boolean enabled)
public void public void
enable() enable()
{ {
setEnabled(true); if (enabled)
return;
this.enabled = true;
if (peer != null)
((MenuItemPeer) peer).setEnabled (true);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -252,7 +252,12 @@ enable() ...@@ -252,7 +252,12 @@ enable()
public void public void
disable() disable()
{ {
setEnabled(false); if (!enabled)
return;
this.enabled = false;
if (peer != null)
((MenuItemPeer) peer).setEnabled (false);
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -258,10 +258,24 @@ public class Polygon implements Shape, Serializable ...@@ -258,10 +258,24 @@ public class Polygon implements Shape, Serializable
*/ */
public Rectangle getBounds() public Rectangle getBounds()
{ {
return getBoundingBox ();
}
/**
* Returns the bounding box of this polygon. This is the smallest
* rectangle with sides parallel to the X axis that will contain this
* polygon.
*
* @return the bounding box for this polygon
* @see #getBounds2D()
* @deprecated use {@link #getBounds()} instead
*/
public Rectangle getBoundingBox()
{
if (bounds == null) if (bounds == null)
{ {
if (npoints == 0) if (npoints == 0)
return bounds = new Rectangle(); return bounds = new Rectangle ();
int i = npoints - 1; int i = npoints - 1;
int minx = xpoints[i]; int minx = xpoints[i];
int maxx = minx; int maxx = minx;
...@@ -280,26 +294,12 @@ public class Polygon implements Shape, Serializable ...@@ -280,26 +294,12 @@ public class Polygon implements Shape, Serializable
else if (y > maxy) else if (y > maxy)
maxy = y; maxy = y;
} }
bounds = new Rectangle(minx, maxy, maxx - minx, maxy - miny); bounds = new Rectangle (minx, maxy, maxx - minx, maxy - miny);
} }
return bounds; return bounds;
} }
/** /**
* Returns the bounding box of this polygon. This is the smallest
* rectangle with sides parallel to the X axis that will contain this
* polygon.
*
* @return the bounding box for this polygon
* @see #getBounds2D()
* @deprecated use {@link #getBounds()} instead
*/
public Rectangle getBoundingBox()
{
return getBounds();
}
/**
* Tests whether or not the specified point is inside this polygon. * Tests whether or not the specified point is inside this polygon.
* *
* @param p the point to test * @param p the point to test
......
...@@ -281,10 +281,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -281,10 +281,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setBounds(Rectangle r) public void setBounds(Rectangle r)
{ {
x = r.x; setBounds (r.x, r.y, r.width, r.height);
y = r.y;
width = r.width;
height = r.height;
} }
/** /**
...@@ -298,10 +295,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -298,10 +295,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setBounds(int x, int y, int width, int height) public void setBounds(int x, int y, int width, int height)
{ {
this.x = x; reshape (x, y, width, height);
this.y = y;
this.width = width;
this.height = height;
} }
/** /**
...@@ -333,7 +327,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -333,7 +327,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void reshape(int x, int y, int width, int height) public void reshape(int x, int y, int width, int height)
{ {
setBounds(x, y, width, height); this.x = x;
this.y = y;
this.width = width;
this.height = height;
} }
/** /**
...@@ -360,8 +357,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -360,8 +357,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setLocation(Point p) public void setLocation(Point p)
{ {
this.x = p.x; setLocation (p.x, p.y);
this.y = p.y;
} }
/** /**
...@@ -374,8 +370,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -374,8 +370,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setLocation(int x, int y) public void setLocation(int x, int y)
{ {
this.x = x; move (x, y);
this.y = y;
} }
/** /**
...@@ -388,7 +383,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -388,7 +383,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void move(int x, int y) public void move(int x, int y)
{ {
setLocation(x, y); this.x = x;
this.y = y;
} }
/** /**
...@@ -426,8 +422,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -426,8 +422,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setSize(Dimension d) public void setSize(Dimension d)
{ {
width = d.width; setSize (d.width, d.height);
height = d.height;
} }
/** /**
...@@ -439,8 +434,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -439,8 +434,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void setSize(int width, int height) public void setSize(int width, int height)
{ {
this.width = width; resize (width, height);
this.height = height;
} }
/** /**
...@@ -452,7 +446,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -452,7 +446,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public void resize(int width, int height) public void resize(int width, int height)
{ {
setSize(width, height); this.width = width;
this.height = height;
} }
/** /**
...@@ -469,9 +464,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -469,9 +464,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public boolean contains(Point p) public boolean contains(Point p)
{ {
return width > 0 && height > 0 return contains (p.x, p.y);
&& p.x >= x && p.x < x + width
&& p.y >= y && p.y < y + height;
} }
/** /**
...@@ -487,9 +480,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -487,9 +480,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public boolean contains(int x, int y) public boolean contains(int x, int y)
{ {
return width > 0 && height > 0 return inside (x, y);
&& x >= this.x && x < this.x + width
&& y >= this.y && y < this.y + height;
} }
/** /**
...@@ -504,9 +495,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -504,9 +495,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public boolean contains(Rectangle r) public boolean contains(Rectangle r)
{ {
return width > 0 && height > 0 && r.width > 0 && r.height > 0 return contains (r.x, r.y, r.width, r.height);
&& r.x >= x && r.x + r.width <= x + width
&& r.y >= y && r.y + r.height <= y + height;
} }
/** /**
...@@ -537,7 +526,9 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable ...@@ -537,7 +526,9 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/ */
public boolean inside(int x, int y) public boolean inside(int x, int y)
{ {
return contains(x, y); return width > 0 && height > 0
&& x >= this.x && x < this.x + width
&& y >= this.y && y < this.y + height;
} }
/** /**
......
...@@ -446,10 +446,25 @@ removeNotify() ...@@ -446,10 +446,25 @@ removeNotify()
public void public void
doLayout() doLayout()
{ {
Component[] list = getComponents(); layout ();
}
/*************************************************************************/
/**
* Lays out this component. This consists of resizing the sole child
* component to its perferred size.
*
* @deprecated This method is deprecated in favor of
* <code>doLayout()</code>.
*/
public void
layout()
{
Component[] list = getComponents ();
if ((list != null) && (list.length > 0)) if ((list != null) && (list.length > 0))
{ {
Dimension dim = list[0].getPreferredSize(); Dimension dim = list[0].getPreferredSize ();
Dimension vp = getViewportSize (); Dimension vp = getViewportSize ();
if (dim.width < vp.width) if (dim.width < vp.width)
...@@ -462,36 +477,21 @@ doLayout() ...@@ -462,36 +477,21 @@ doLayout()
if (peer != null) if (peer != null)
peer.childResized (dim.width, dim.height); peer.childResized (dim.width, dim.height);
list[0].resize (dim); list[0].setSize (dim);
Point p = getScrollPosition(); Point p = getScrollPosition ();
if (p.x > dim.width) if (p.x > dim.width)
p.x = dim.width; p.x = dim.width;
if (p.y > dim.height) if (p.y > dim.height)
p.y = dim.height; p.y = dim.height;
setScrollPosition(p); setScrollPosition (p);
} }
} }
/*************************************************************************/ /*************************************************************************/
/** /**
* Lays out this component. This consists of resizing the sole child
* component to its perferred size.
*
* @deprecated This method is deprecated in favor of
* <code>doLayout()</code>.
*/
public void
layout()
{
doLayout();
}
/*************************************************************************/
/**
* This method overrides its superclass method to ensure no layout * This method overrides its superclass method to ensure no layout
* manager is set for this container. <code>ScrollPane</code>'s do * manager is set for this container. <code>ScrollPane</code>'s do
* not have layout managers. * not have layout managers.
......
...@@ -333,7 +333,7 @@ setMinimum(int minimum) ...@@ -333,7 +333,7 @@ setMinimum(int minimum)
public int public int
getVisibleAmount() getVisibleAmount()
{ {
return(visibleAmount); return getVisible ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -350,7 +350,7 @@ getVisibleAmount() ...@@ -350,7 +350,7 @@ getVisibleAmount()
public int public int
getVisible() getVisible()
{ {
return(getVisibleAmount()); return visibleAmount;
} }
/*************************************************************************/ /*************************************************************************/
...@@ -438,7 +438,7 @@ setValues(int value, int visibleAmount, int minimum, int maximum) ...@@ -438,7 +438,7 @@ setValues(int value, int visibleAmount, int minimum, int maximum)
public int public int
getUnitIncrement() getUnitIncrement()
{ {
return(lineIncrement); return getLineIncrement ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -455,7 +455,7 @@ getUnitIncrement() ...@@ -455,7 +455,7 @@ getUnitIncrement()
public int public int
getLineIncrement() getLineIncrement()
{ {
return(lineIncrement); return lineIncrement;
} }
/*************************************************************************/ /*************************************************************************/
...@@ -469,26 +469,7 @@ getLineIncrement() ...@@ -469,26 +469,7 @@ getLineIncrement()
public synchronized void public synchronized void
setUnitIncrement(int unitIncrement) setUnitIncrement(int unitIncrement)
{ {
if (unitIncrement < 0) setLineIncrement (unitIncrement);
throw new IllegalArgumentException("Unit increment less than zero.");
int range = maximum - minimum;
if (unitIncrement > range)
{
if (range == 0)
unitIncrement = 1;
else
unitIncrement = range;
}
if (unitIncrement == lineIncrement)
return;
lineIncrement = unitIncrement;
ScrollbarPeer sp = (ScrollbarPeer)getPeer();
if (sp != null)
sp.setLineIncrement(lineIncrement);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -505,7 +486,26 @@ setUnitIncrement(int unitIncrement) ...@@ -505,7 +486,26 @@ setUnitIncrement(int unitIncrement)
public void public void
setLineIncrement(int lineIncrement) setLineIncrement(int lineIncrement)
{ {
setUnitIncrement(lineIncrement); if (lineIncrement < 0)
throw new IllegalArgumentException ("Unit increment less than zero.");
int range = maximum - minimum;
if (lineIncrement > range)
{
if (range == 0)
lineIncrement = 1;
else
lineIncrement = range;
}
if (lineIncrement == this.lineIncrement)
return;
this.lineIncrement = lineIncrement;
ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
if (sp != null)
sp.setLineIncrement (this.lineIncrement);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -519,7 +519,7 @@ setLineIncrement(int lineIncrement) ...@@ -519,7 +519,7 @@ setLineIncrement(int lineIncrement)
public int public int
getBlockIncrement() getBlockIncrement()
{ {
return(pageIncrement); return getPageIncrement ();
} }
/*************************************************************************/ /*************************************************************************/
...@@ -536,7 +536,7 @@ getBlockIncrement() ...@@ -536,7 +536,7 @@ getBlockIncrement()
public int public int
getPageIncrement() getPageIncrement()
{ {
return(pageIncrement); return pageIncrement;
} }
/*************************************************************************/ /*************************************************************************/
...@@ -550,26 +550,7 @@ getPageIncrement() ...@@ -550,26 +550,7 @@ getPageIncrement()
public synchronized void public synchronized void
setBlockIncrement(int blockIncrement) setBlockIncrement(int blockIncrement)
{ {
if (blockIncrement < 0) setPageIncrement (blockIncrement);
throw new IllegalArgumentException("Block increment less than zero.");
int range = maximum - minimum;
if (blockIncrement > range)
{
if (range == 0)
blockIncrement = 1;
else
blockIncrement = range;
}
if (blockIncrement == pageIncrement)
return;
pageIncrement = blockIncrement;
ScrollbarPeer sp = (ScrollbarPeer)getPeer();
if (sp != null)
sp.setPageIncrement(pageIncrement);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -586,7 +567,26 @@ setBlockIncrement(int blockIncrement) ...@@ -586,7 +567,26 @@ setBlockIncrement(int blockIncrement)
public void public void
setPageIncrement(int pageIncrement) setPageIncrement(int pageIncrement)
{ {
setBlockIncrement(pageIncrement); if (pageIncrement < 0)
throw new IllegalArgumentException ("Block increment less than zero.");
int range = maximum - minimum;
if (pageIncrement > range)
{
if (range == 0)
pageIncrement = 1;
else
pageIncrement = range;
}
if (pageIncrement == this.pageIncrement)
return;
this.pageIncrement = pageIncrement;
ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
if (sp != null)
sp.setPageIncrement (this.pageIncrement);
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -288,13 +288,7 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -288,13 +288,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension getMinimumSize (int rows, int columns) public Dimension getMinimumSize (int rows, int columns)
{ {
TextAreaPeer peer = (TextAreaPeer) getPeer (); return minimumSize (rows, columns);
// Sun returns Dimension (0,0) in this case.
if (peer == null)
return new Dimension (0, 0);
return peer.getMinimumSize (rows, columns);
} }
/** /**
...@@ -311,7 +305,7 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -311,7 +305,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension minimumSize () public Dimension minimumSize ()
{ {
return getMinimumSize (getRows (), getColumns ()); return minimumSize (getRows (), getColumns ());
} }
/** /**
...@@ -333,7 +327,13 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -333,7 +327,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension minimumSize (int rows, int columns) public Dimension minimumSize (int rows, int columns)
{ {
return getMinimumSize (rows, columns); TextAreaPeer peer = (TextAreaPeer) getPeer ();
// Sun returns Dimension (0,0) in this case.
if (peer == null)
return new Dimension (0, 0);
return peer.getMinimumSize (rows, columns);
} }
/** /**
...@@ -366,13 +366,7 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -366,13 +366,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension getPreferredSize (int rows, int columns) public Dimension getPreferredSize (int rows, int columns)
{ {
TextAreaPeer peer = (TextAreaPeer) getPeer (); return preferredSize (rows, columns);
// Sun returns Dimension (0,0) in this case.
if (peer == null)
return new Dimension (0, 0);
return peer.getPreferredSize (rows, columns);
} }
/** /**
...@@ -389,7 +383,7 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -389,7 +383,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension preferredSize () public Dimension preferredSize ()
{ {
return getPreferredSize (getRows (), getColumns ()); return preferredSize (getRows (), getColumns ());
} }
/** /**
...@@ -411,7 +405,13 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -411,7 +405,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/ */
public Dimension preferredSize (int rows, int columns) public Dimension preferredSize (int rows, int columns)
{ {
return getPreferredSize (rows, columns); TextAreaPeer peer = (TextAreaPeer) getPeer ();
// Sun returns Dimension (0,0) in this case.
if (peer == null)
return new Dimension (0, 0);
return peer.getPreferredSize (rows, columns);
} }
/** /**
...@@ -440,59 +440,59 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -440,59 +440,59 @@ public class TextArea extends TextComponent implements java.io.Serializable
/** /**
* Append the specified text to the end of the current text. * Append the specified text to the end of the current text.
* *
* @param text The text to append. * @param str The text to append.
*/ */
public void append (String str) public void append (String str)
{ {
TextAreaPeer peer = (TextAreaPeer) getPeer (); appendText (str);
if (peer == null)
return;
peer.insert (str, peer.getText().length ());
} }
/** /**
* Append the specified text to the end of the current text. * Append the specified text to the end of the current text.
* *
* @param text The text to append. * @param str The text to append.
* *
* @deprecated This method is deprecated in favor of * @deprecated This method is deprecated in favor of
* <code>append ()</code>. * <code>append ()</code>.
*/ */
public void appendText (String text) public void appendText (String str)
{ {
append (text); TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.insert (str, peer.getText().length ());
} }
/** /**
* Insert the specified text at the specified position. The first * Insert the specified text at the specified position. The first
* character in the text area is at position zero. * character in the text area is at position zero.
* *
* @param text The text to insert. * @param str The text to insert.
* @param pos The position at which to insert text. * @param pos The position at which to insert text.
*/ */
public void insert (String text, int pos) public void insert (String str, int pos)
{ {
TextAreaPeer peer = (TextAreaPeer) getPeer (); insertText (str, pos);
if (peer == null)
return;
peer.insert (text, pos);
} }
/** /**
* Insert the specified text at the specified position. The first * Insert the specified text at the specified position. The first
* character in the text area is at position zero. * character in the text area is at position zero.
* *
* @param text The text to insert. * @param str The text to insert.
* @param pos The position at which to insert text. * @param pos The position at which to insert text.
* *
* @deprecated This method is depcreated in favor of * @deprecated This method is deprecated in favor of
* <code>insert ()</code>. * <code>insert ()</code>.
*/ */
public void insertText (String text, int pos) public void insertText (String str, int pos)
{ {
insert (text, pos); TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.insert (str, pos);
} }
/** /**
...@@ -503,17 +503,13 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -503,17 +503,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
* length of the replacement text may differ from the length of the * length of the replacement text may differ from the length of the
* text that is replaced. * text that is replaced.
* *
* @param text The new text for the range. * @param str The new text for the range.
* @param start The start position of the replacement range. * @param start The start position of the replacement range.
* @param end The end position of the replacement range. * @param end The end position of the replacement range.
*/ */
public void replaceRange (String text, int start, int end) public void replaceRange (String str, int start, int end)
{ {
TextAreaPeer peer = (TextAreaPeer) getPeer (); replaceText (str, start, end);
if (peer == null)
return;
peer.replaceRange (text, start, end);
} }
/** /**
...@@ -524,16 +520,20 @@ public class TextArea extends TextComponent implements java.io.Serializable ...@@ -524,16 +520,20 @@ public class TextArea extends TextComponent implements java.io.Serializable
* length of the replacement text may differ from the length of the * length of the replacement text may differ from the length of the
* text that is replaced. * text that is replaced.
* *
* @param text The new text for the range. * @param str The new text for the range.
* @param start The start position of the replacement range. * @param start The start position of the replacement range.
* @param end The end position of the replacement range. * @param end The end position of the replacement range.
* *
* @deprecated This method is deprecated in favor of * @deprecated This method is deprecated in favor of
* <code>replaceRange ()</code>. * <code>replaceRange ()</code>.
*/ */
public void replaceText (String text, int start, int end) public void replaceText (String str, int start, int end)
{ {
replaceRange (text, start, end); TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer == null)
return;
peer.replaceRange (str, start, end);
} }
/** /**
......
...@@ -212,11 +212,7 @@ getEchoChar() ...@@ -212,11 +212,7 @@ getEchoChar()
public void public void
setEchoChar(char echoChar) setEchoChar(char echoChar)
{ {
this.echoChar = echoChar; setEchoCharacter (echoChar);
TextFieldPeer tfp = (TextFieldPeer)getPeer();
if (tfp != null)
tfp.setEchoChar(echoChar);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -233,7 +229,11 @@ setEchoChar(char echoChar) ...@@ -233,7 +229,11 @@ setEchoChar(char echoChar)
public void public void
setEchoCharacter(char echoChar) setEchoCharacter(char echoChar)
{ {
setEchoChar(echoChar); this.echoChar = echoChar;
TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer != null)
peer.setEchoChar (echoChar);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -264,7 +264,7 @@ echoCharIsSet() ...@@ -264,7 +264,7 @@ echoCharIsSet()
public Dimension public Dimension
getMinimumSize() getMinimumSize()
{ {
return(getMinimumSize(getColumns())); return getMinimumSize (getColumns ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -278,11 +278,7 @@ getMinimumSize() ...@@ -278,11 +278,7 @@ getMinimumSize()
public Dimension public Dimension
getMinimumSize(int columns) getMinimumSize(int columns)
{ {
TextFieldPeer tfp = (TextFieldPeer)getPeer(); return minimumSize (columns);
if (tfp == null)
return(null); // FIXME: What do we do if there is no peer?
return(tfp.getMinimumSize(columns));
} }
/*************************************************************************/ /*************************************************************************/
...@@ -292,13 +288,13 @@ getMinimumSize(int columns) ...@@ -292,13 +288,13 @@ getMinimumSize(int columns)
* *
* @return The minimum size for this text field. * @return The minimum size for this text field.
* *
* @deprecated This method is depcreated in favor of * @deprecated This method is deprecated in favor of
* <code>getMinimumSize()</code>. * <code>getMinimumSize()</code>.
*/ */
public Dimension public Dimension
minimumSize() minimumSize()
{ {
return(getMinimumSize(getColumns())); return minimumSize (getColumns ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -315,7 +311,11 @@ minimumSize() ...@@ -315,7 +311,11 @@ minimumSize()
public Dimension public Dimension
minimumSize(int columns) minimumSize(int columns)
{ {
return(getMinimumSize(columns)); TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer == null)
return null; // FIXME: What do we do if there is no peer?
return peer.getMinimumSize (columns);
} }
/*************************************************************************/ /*************************************************************************/
...@@ -328,7 +328,7 @@ minimumSize(int columns) ...@@ -328,7 +328,7 @@ minimumSize(int columns)
public Dimension public Dimension
getPreferredSize() getPreferredSize()
{ {
return(getPreferredSize(getColumns())); return getPreferredSize (getColumns ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -342,12 +342,7 @@ getPreferredSize() ...@@ -342,12 +342,7 @@ getPreferredSize()
public Dimension public Dimension
getPreferredSize(int columns) getPreferredSize(int columns)
{ {
TextFieldPeer tfp = (TextFieldPeer)getPeer(); return preferredSize (columns);
if (tfp == null)
{
return new Dimension(0, 0);
}
return(tfp.getPreferredSize(columns));
} }
/*************************************************************************/ /*************************************************************************/
...@@ -363,7 +358,7 @@ getPreferredSize(int columns) ...@@ -363,7 +358,7 @@ getPreferredSize(int columns)
public Dimension public Dimension
preferredSize() preferredSize()
{ {
return(getPreferredSize(getColumns())); return preferredSize (getColumns ());
} }
/*************************************************************************/ /*************************************************************************/
...@@ -380,7 +375,11 @@ preferredSize() ...@@ -380,7 +375,11 @@ preferredSize()
public Dimension public Dimension
preferredSize(int columns) preferredSize(int columns)
{ {
return(getPreferredSize(columns)); TextFieldPeer peer = (TextFieldPeer) getPeer ();
if (peer == null)
return new Dimension (0, 0);
return peer.getPreferredSize (columns);
} }
/*************************************************************************/ /*************************************************************************/
......
...@@ -87,24 +87,24 @@ public class RenderContext implements Cloneable ...@@ -87,24 +87,24 @@ public class RenderContext implements Cloneable
public void preConcatenateTransform(AffineTransform pre) public void preConcatenateTransform(AffineTransform pre)
{ {
xform.preConcatenate(pre); preConcetenateTransform (pre);
} }
/** @deprecated Sun can't spell concatenate */ /** @deprecated */
public void preConcetenateTransform(AffineTransform pre) public void preConcetenateTransform(AffineTransform pre)
{ {
preConcetenateTransform(pre); xform.preConcatenate (pre);
} }
public void concatenateTransform(AffineTransform post) public void concatenateTransform(AffineTransform post)
{ {
xform.concatenate(post); concetenateTransform (post);
} }
/** @deprecated Sun can't spell concatenate */ /** @deprecated */
public void concetenateTransform(AffineTransform post) public void concetenateTransform(AffineTransform post)
{ {
concatenateTransform(post); xform.concatenate (post);
} }
public AffineTransform getTransform() public AffineTransform getTransform()
......
...@@ -80,7 +80,7 @@ public class JApplet extends Applet ...@@ -80,7 +80,7 @@ public class JApplet extends Applet
public Dimension getPreferredSize() public Dimension getPreferredSize()
{ {
Dimension d = super.getPreferredSize(); Dimension d = super.getPreferredSize();
System.out.println("JFrame.getPrefSize(): " + d + " , comp="+countComponents() + ", layout=" + getLayout()); System.out.println("JFrame.getPrefSize(): " + d + " , comp="+ getComponentCount () + ", layout=" + getLayout());
return d; return d;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment