+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>
* gnu/java/nio/DatagramChannelImpl.java
public Dimension getMinimumSize (int rows)
{
- int dims[] = new int[2];
-
- getSize (rows, dims);
- return (new Dimension (dims[0], dims[1]));
+ return minimumSize (rows);
}
public Dimension getPreferredSize (int rows)
{
- int dims[] = new int[2];
-
- getSize (rows, dims);
- return (new Dimension (dims[0], dims[1]));
+ return preferredSize (rows);
}
public native int[] getSelectedIndexes ();
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)
{
- return (getPreferredSize (rows));
+ int dims[] = new int[2];
+
+ getSize (rows, dims);
+ return new Dimension (dims[0], dims[1]);
}
public void removeAll ()
if (constraints != null && ! (constraints instanceof 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))
center = 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)
-{
- addLayoutComponent(component, constraints);
-}
-
-/*************************************************************************/
-
/**
* Removes the specified component from the layout.
*
if (! (constraints instanceof String))
throw new IllegalArgumentException ("Object " + constraints
+ " 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
*/
public void addLayoutComponent (String name, Component comp)
{
- addLayoutComponent (comp, name);
+ tab.put (name, comp);
}
/** Cause the first component in the container to be displayed.
public Checkbox
getSelectedCheckbox()
{
- return(selectedCheckbox);
-}
+ return getCurrent ();
+}
/*************************************************************************/
public void
setSelectedCheckbox(Checkbox selectedCheckbox)
{
- if (this.selectedCheckbox != null)
- {
- if (this.selectedCheckbox.getCheckboxGroup() != this)
- return;
-
- this.selectedCheckbox.setState(false);
- }
-
- this.selectedCheckbox = selectedCheckbox;
- if (selectedCheckbox != null)
- selectedCheckbox.setState(true);
+ setCurrent (selectedCheckbox);
}
/*************************************************************************/
public void
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);
}
/*************************************************************************/
public int
getItemCount()
{
- return(pItems.size());
+ return countItems ();
}
/*************************************************************************/
*/
public void setEnabled(boolean b)
{
- this.enabled = b;
- if (peer != null)
- peer.setEnabled(b);
+ enable (b);
}
/**
*/
public void enable()
{
- setEnabled(true);
+ this.enabled = true;
+ if (peer != null)
+ peer.setEnabled (true);
}
/**
*/
public void enable(boolean b)
{
- setEnabled(b);
+ if (b)
+ enable ();
+ else
+ disable ();
}
/**
*/
public void disable()
{
- setEnabled(false);
+ this.enabled = false;
+ if (peer != null)
+ peer.setEnabled (false);
}
/**
// Inspection by subclassing shows that Sun's implementation calls
// show(boolean) which then calls show() or hide(). It is the show()
// method that is overriden in subclasses like Window.
- if (b)
- show();
- else
- hide();
+ show (b);
}
/**
*/
public void show(boolean b)
{
- setVisible(b);
+ if (b)
+ show ();
+ else
+ hide ();
}
/**
*/
public Point getLocation()
{
- return new Point(x, y);
+ return location ();
}
/**
*/
public Point location()
{
- return getLocation();
+ return new Point (x, y);
}
/**
*/
public void setLocation(int x, int 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);
+ move (x, 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);
}
/**
*/
public Dimension getSize()
{
- return new Dimension(width, height);
+ return size ();
}
/**
*/
public Dimension size()
{
- return getSize();
+ return new Dimension (width, height);
}
/**
*/
public void setSize(int width, int 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);
+ resize (width, 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);
}
/**
*/
public void setSize(Dimension d)
{
- setSize(d.width, d.height);
+ resize (d);
}
/**
*/
public void resize(Dimension d)
{
- setSize(d.width, d.height);
+ resize (d.width, d.height);
}
/**
*/
public Rectangle getBounds()
{
- return new Rectangle(x, y, width, height);
+ return bounds ();
}
/**
*/
public Rectangle bounds()
{
- return getBounds();
+ return new Rectangle (x, y, width, height);
}
/**
*/
public void setBounds(int x, int y, int w, int h)
{
- if (this.x == x && this.y == y && width == w && height == h)
- return;
- invalidate();
- this.x = x;
- this.y = y;
- width = w;
- height = h;
- if (peer != null)
- peer.setBounds(x, y, w, h);
+ reshape (x, y, w, h);
}
/**
*
* @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 w the width of the rectangle
- * @param h the height of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
* @deprecated use {@link #setBounds(int, int, int, int)} instead
*/
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);
}
/**
*/
public void setBounds(Rectangle r)
{
- setBounds(r.x, r.y, r.width, r.height);
+ setBounds (r.x, r.y, r.width, r.height);
}
/**
*/
public void doLayout()
{
- // nothing to do unless we're a container
+ layout ();
}
/**
*/
public void layout()
{
- doLayout();
+ // Nothing to do unless we're a container.
}
/**
*/
public boolean contains(int x, int y)
{
- return x >= 0 && y >= 0 && x < width && y < height;
+ return inside (x, y);
}
/**
*/
public boolean inside(int x, int y)
{
- return contains(x, y);
+ return x >= 0 && y >= 0 && x < width && y < height;
}
/**
*/
public boolean contains(Point p)
{
- return contains(p.x, p.y);
+ return contains (p.x, p.y);
}
/**
*/
public Component getComponentAt(int x, int y)
{
- return contains(x, y) ? this : null;
+ return locate (x, y);
}
/**
*/
public Component locate(int x, int y)
{
- return getComponentAt(x, y);
+ return contains (x, y) ? this : null;
}
/**
*/
public Component getComponentAt(Point p)
{
- return getComponentAt(p.x, p.y);
+ return getComponentAt (p.x, p.y);
}
/**
*/
public int getComponentCount()
{
- return ncomponents;
+ return countComponents ();
}
/**
*/
public int countComponents()
{
- return getComponentCount();
+ return ncomponents;
}
/**
*/
public Insets getInsets()
{
- if (peer == null)
- return new Insets(0, 0, 0, 0);
-
- return ((ContainerPeer) peer).getInsets();
+ return insets ();
}
/**
*/
public Insets insets()
{
- return getInsets();
+ if (peer == null)
+ return new Insets (0, 0, 0, 0);
+
+ return ((ContainerPeer) peer).getInsets ();
}
/**
*/
public void doLayout()
{
- if (layoutMgr != null)
- layoutMgr.layoutContainer(this);
+ layout ();
}
/**
*/
public void layout()
{
- doLayout();
+ if (layoutMgr != null)
+ layoutMgr.layoutContainer (this);
}
/**
*/
public Dimension getPreferredSize()
{
- return preferredSize();
+ return preferredSize ();
}
/**
*/
public Dimension preferredSize()
{
- if (layoutMgr != null)
- return layoutMgr.preferredLayoutSize(this);
- else
- return super.preferredSize();
+ if (layoutMgr != null)
+ return layoutMgr.preferredLayoutSize (this);
+ else
+ return super.preferredSize ();
}
/**
*/
public Dimension getMinimumSize()
{
- return minimumSize();
+ return minimumSize ();
}
/**
*/
public Dimension minimumSize()
{
- if (layoutMgr != null)
- return layoutMgr.minimumLayoutSize(this);
- else
- return super.minimumSize();
+ if (layoutMgr != null)
+ return layoutMgr.minimumLayoutSize (this);
+ else
+ return super.minimumSize ();
}
/**
*/
public Component getComponentAt(int x, int 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;
- }
+ return locate (x, 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;
+ }
}
/**
*/
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 int
getMaxDescent()
{
- return(getDescent());
+ return getMaxDecent ();
}
/*************************************************************************/
public int
getMaxDecent()
{
- return(getMaxDescent());
+ return getDescent ();
}
/*************************************************************************/
public void layoutContainer (Container parent)
{
- arrangeGrid (parent);
+ arrangeGrid (parent);
}
public float getLayoutAlignmentX (Container target)
*/
protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect)
{
- adjustForGravity (gbc, rect);
+ // FIXME
+ throw new Error ("Not implemented");
}
/**
*/
protected void ArrangeGrid (Container parent)
{
- arrangeGrid (parent);
+ Component[] components = parent.getComponents();
+
+ if (components.length == 0)
+ return;
+
+ GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
+ if (info.cols == 0 && info.rows == 0)
+ return;
+ layoutInfo = info;
+
+ // DEBUG
+ //dumpLayoutInfo (layoutInfo);
+
+ for(int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx);
+ int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy);
+ int cellw = sumIntArray(layoutInfo.colWidths,
+ constraints.gridx + constraints.gridwidth) - cellx;
+ int cellh = sumIntArray(layoutInfo.rowHeights,
+ constraints.gridy + constraints.gridheight) - celly;
+
+ Insets insets = constraints.insets;
+ if (insets != null)
+ {
+ cellx += insets.left;
+ celly += insets.top;
+ cellw -= insets.left + insets.right;
+ cellh -= insets.top + insets.bottom;
+ }
+
+ Dimension dim = component.getPreferredSize();
+
+ // Note: Documentation says that padding is added on both sides, but
+ // visual inspection shows that the Sun implementation only adds it
+ // once, so we do the same.
+ dim.width += constraints.ipadx;
+ dim.height += constraints.ipady;
+
+ switch(constraints.fill)
+ {
+ case GridBagConstraints.HORIZONTAL:
+ dim.width = cellw;
+ break;
+ case GridBagConstraints.VERTICAL:
+ dim.height = cellh;
+ break;
+ case GridBagConstraints.BOTH:
+ dim.width = cellw;
+ dim.height = cellh;
+ break;
+ }
+
+ int x;
+ int y;
+
+ switch(constraints.anchor)
+ {
+ case GridBagConstraints.NORTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.WEST:
+ x = cellx;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.EAST:
+ x = cellx + cellw - dim.width;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.NORTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly;
+ break;
+ case GridBagConstraints.NORTHWEST:
+ x = cellx;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.SOUTHWEST:
+ x = cellx;
+ y = celly + cellh - dim.height;
+ break;
+ default:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ }
+
+ component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height);
+ }
+
+ // DEBUG
+ //dumpLayoutInfo (layoutInfo);
}
/**
*/
protected GridBagLayoutInfo GetLayoutInfo (Container parent, int sizeflag)
{
- return getLayoutInfo (parent, sizeflag);
+ if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
+ throw new IllegalArgumentException();
+
+ Dimension parentDim = parent.getSize ();
+ Insets parentInsets = parent.getInsets ();
+ parentDim.width -= parentInsets.left + parentInsets.right;
+ parentDim.height -= parentInsets.top + parentInsets.bottom;
+
+ int x = 0;
+ int y = 0;
+ int max_x = 0;
+ int max_y = 0;
+
+ // first we figure out how many rows/columns
+ Component[] components = parent.getComponents();
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ if(constraints.gridx == GridBagConstraints.RELATIVE)
+ constraints.gridx = x;
+
+ if(constraints.gridy == GridBagConstraints.RELATIVE)
+ constraints.gridy = y;
+
+ max_x = Math.max(max_x,
+ constraints.gridx + Math.max(1, constraints.gridwidth));
+ max_y = Math.max(max_y,
+ constraints.gridy + Math.max(1, constraints.gridheight));
+
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ x = 0;
+ y++;
+ }
+ else
+ {
+ x = constraints.gridx + Math.max(1, constraints.gridwidth);
+ y = constraints.gridy;
+ }
+ }
+
+ GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y);
+
+ for (x = 0; x <= max_x; x++)
+ {
+ if(columnWidths != null && columnWidths.length > x)
+ {
+ info.colWidths[x] = columnWidths[x];
+ }
+ if(columnWeights != null && columnWeights.length > x)
+ {
+ info.colWeights[x] = columnWeights[x];
+ }
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ // first we fix up any REMAINDER cells
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ constraints.gridwidth = max_x - constraints.gridx;
+ }
+ if(constraints.gridheight == GridBagConstraints.REMAINDER)
+ {
+ constraints.gridheight = max_y - constraints.gridy;
+ }
+
+ if(constraints.gridx + constraints.gridwidth - 1 == x)
+ {
+ int width = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().width :
+ component.getMinimumSize().width;
+ if(constraints.insets != null)
+ {
+ width += constraints.insets.left + constraints.insets.right;
+ }
+ width += constraints.ipadx;
+ for(int w = 1; w < constraints.gridwidth; w++)
+ {
+ width -= info.colWidths[x - w];
+ }
+ info.colWidths[x] = Math.max(info.colWidths[x], width);
+ info.colWeights[x] =
+ Math.max(info.colWeights[x], constraints.weightx);
+ }
+ }
+ }
+
+ for (y = 0; y <= max_y; y++)
+ {
+ if(rowHeights != null && rowHeights.length > y)
+ {
+ info.rowHeights[y] = rowHeights[y];
+ }
+ if(rowWeights != null && rowWeights.length > y)
+ {
+ info.rowWeights[y] = rowWeights[y];
+ }
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ if(constraints.gridy + constraints.gridheight - 1 == y)
+ {
+ int height = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().height :
+ component.getMinimumSize().height;
+ if(constraints.insets != null)
+ {
+ height += constraints.insets.top + constraints.insets.bottom;
+ }
+ height += constraints.ipady;
+ for(int h = 1; h < constraints.gridheight; h++)
+ {
+ height -= info.rowHeights[y - h];
+ }
+ info.rowHeights[y] = Math.max(info.rowHeights[y], height);
+ info.rowWeights[y] =
+ Math.max(info.rowWeights[y], constraints.weighty);
+ }
+ }
+ }
+
+ calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
+ calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+
+ int totalWidth = sumIntArray(info.colWidths);
+ int totalHeight = sumIntArray(info.rowHeights);
+ info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
+ info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
+
+ // DEBUG
+ //dumpLayoutInfo (info);
+
+ return info;
}
/**
*/
protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info)
{
- return getMinSize (parent, info);
+ if (parent == null || info == null)
+ return new Dimension (0, 0);
+
+ Insets insets = parent.getInsets();
+ int width = sumIntArray (info.colWidths) + insets.left + insets.right;
+ int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom;
+ return new Dimension (width, height);
}
/**
*/
protected Dimension getMinSize (Container parent, GridBagLayoutInfo info)
{
- if (parent == null || info == null)
- return new Dimension (0, 0);
-
- Insets insets = parent.getInsets();
- int width = sumIntArray (info.colWidths) + insets.left + insets.right;
- int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom;
- return new Dimension (width, height);
+ return GetMinSize (parent, info);
}
private void calcCellSizes (int[] sizes, double[] weights, int range)
*/
protected void arrangeGrid (Container parent)
{
- Component[] components = parent.getComponents();
-
- if (components.length == 0)
- return;
-
- GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
- if (info.cols == 0 && info.rows == 0)
- return;
- layoutInfo = info;
-
- // DEBUG
- //dumpLayoutInfo (layoutInfo);
-
- for(int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx);
- int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy);
- int cellw = sumIntArray(layoutInfo.colWidths,
- constraints.gridx + constraints.gridwidth) - cellx;
- int cellh = sumIntArray(layoutInfo.rowHeights,
- constraints.gridy + constraints.gridheight) - celly;
-
- Insets insets = constraints.insets;
- if (insets != null)
- {
- cellx += insets.left;
- celly += insets.top;
- cellw -= insets.left + insets.right;
- cellh -= insets.top + insets.bottom;
- }
-
- Dimension dim = component.preferredSize();
-
- // Note: Documentation says that padding is added on both sides, but
- // visual inspection shows that the Sun implementation only adds it
- // once, so we do the same.
- dim.width += constraints.ipadx;
- dim.height += constraints.ipady;
-
- switch(constraints.fill)
- {
- case GridBagConstraints.HORIZONTAL:
- dim.width = cellw;
- break;
- case GridBagConstraints.VERTICAL:
- dim.height = cellh;
- break;
- case GridBagConstraints.BOTH:
- dim.width = cellw;
- dim.height = cellh;
- break;
- }
-
- int x;
- int y;
-
- switch(constraints.anchor)
- {
- case GridBagConstraints.NORTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly;
- break;
- case GridBagConstraints.SOUTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.WEST:
- x = cellx;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.EAST:
- x = cellx + cellw - dim.width;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.NORTHEAST:
- x = cellx + cellw - dim.width;
- y = celly;
- break;
- case GridBagConstraints.NORTHWEST:
- x = cellx;
- y = celly;
- break;
- case GridBagConstraints.SOUTHEAST:
- x = cellx + cellw - dim.width;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.SOUTHWEST:
- x = cellx;
- y = celly + cellh - dim.height;
- break;
- default:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + (cellh - dim.height) / 2;
- break;
- }
-
- component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height);
- }
-
- // DEBUG
- //dumpLayoutInfo (layoutInfo);
-
+ ArrangeGrid (parent);
}
/**
*/
protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag)
{
- if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
- throw new IllegalArgumentException();
-
- Dimension parentDim = parent.size();
- Insets parentInsets = parent.insets();
- parentDim.width -= parentInsets.left + parentInsets.right;
- parentDim.height -= parentInsets.top + parentInsets.bottom;
-
- int x = 0;
- int y = 0;
- int max_x = 0;
- int max_y = 0;
-
- // first we figure out how many rows/columns
- Component[] components = parent.getComponents();
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- if(constraints.gridx == GridBagConstraints.RELATIVE)
- constraints.gridx = x;
-
- if(constraints.gridy == GridBagConstraints.RELATIVE)
- constraints.gridy = y;
-
- max_x = Math.max(max_x,
- constraints.gridx + Math.max(1, constraints.gridwidth));
- max_y = Math.max(max_y,
- constraints.gridy + Math.max(1, constraints.gridheight));
-
- if(constraints.gridwidth == GridBagConstraints.REMAINDER)
- {
- x = 0;
- y++;
- }
- else
- {
- x = constraints.gridx + Math.max(1, constraints.gridwidth);
- y = constraints.gridy;
- }
- }
-
- GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y);
-
- for (x = 0; x <= max_x; x++)
- {
- if(columnWidths != null && columnWidths.length > x)
- {
- info.colWidths[x] = columnWidths[x];
- }
- if(columnWeights != null && columnWeights.length > x)
- {
- info.colWeights[x] = columnWeights[x];
- }
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- // first we fix up any REMAINDER cells
- if(constraints.gridwidth == GridBagConstraints.REMAINDER)
- {
- constraints.gridwidth = max_x - constraints.gridx;
- }
- if(constraints.gridheight == GridBagConstraints.REMAINDER)
- {
- constraints.gridheight = max_y - constraints.gridy;
- }
-
- if(constraints.gridx + constraints.gridwidth - 1 == x)
- {
- int width = (sizeflag == PREFERREDSIZE) ?
- component.preferredSize().width :
- component.minimumSize().width;
- if(constraints.insets != null)
- {
- width += constraints.insets.left + constraints.insets.right;
- }
- width += constraints.ipadx;
- for(int w = 1; w < constraints.gridwidth; w++)
- {
- width -= info.colWidths[x - w];
- }
- info.colWidths[x] = Math.max(info.colWidths[x], width);
- info.colWeights[x] =
- Math.max(info.colWeights[x], constraints.weightx);
- }
- }
- }
-
- for (y = 0; y <= max_y; y++)
- {
- if(rowHeights != null && rowHeights.length > y)
- {
- info.rowHeights[y] = rowHeights[y];
- }
- if(rowWeights != null && rowWeights.length > y)
- {
- info.rowWeights[y] = rowWeights[y];
- }
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- if(constraints.gridy + constraints.gridheight - 1 == y)
- {
- int height = (sizeflag == PREFERREDSIZE) ?
- component.preferredSize().height :
- component.minimumSize().height;
- if(constraints.insets != null)
- {
- height += constraints.insets.top + constraints.insets.bottom;
- }
- height += constraints.ipady;
- for(int h = 1; h < constraints.gridheight; h++)
- {
- height -= info.rowHeights[y - h];
- }
- info.rowHeights[y] = Math.max(info.rowHeights[y], height);
- info.rowWeights[y] =
- Math.max(info.rowWeights[y], constraints.weighty);
- }
- }
- }
-
- calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
- calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
-
- int totalWidth = sumIntArray(info.colWidths);
- int totalHeight = sumIntArray(info.rowHeights);
- info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
- info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
-
- // DEBUG
- //dumpLayoutInfo (info);
-
- return info;
+ return GetLayoutInfo (parent, sizeflag);
}
/**
*/
protected void adjustForGravity (GridBagConstraints gbc, Rectangle rect)
{
- // FIXME
- throw new Error ("Not implemented");
+ AdjustForGravity (gbc, rect);
}
}
{
/**
* Adds the specified component to the layout, with the specified
- * constraint object.
+ * constraints object.
*
* @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.
public int
getItemCount()
{
- return(items.size());
+ return countItems ();
}
/*************************************************************************/
public int
countItems()
{
- return(getItemCount());
+ return items.size ();
}
/*************************************************************************/
public boolean
isMultipleMode()
{
- return(multipleMode);
+ return allowsMultipleSelections ();
}
/*************************************************************************/
public boolean
allowsMultipleSelections()
{
- return(multipleMode);
+ return multipleMode;
}
/*************************************************************************/
public void
setMultipleMode(boolean multipleMode)
{
- this.multipleMode = multipleMode;
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.setMultipleMode (multipleMode);
- }
+ setMultipleSelections (multipleMode);
}
/*************************************************************************/
public void
setMultipleSelections(boolean multipleMode)
{
- setMultipleMode(multipleMode);
+ this.multipleMode = multipleMode;
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.setMultipleMode (multipleMode);
}
/*************************************************************************/
public Dimension
getMinimumSize()
{
- return(getMinimumSize(rows));
+ return getMinimumSize (getRows ());
}
/*************************************************************************/
public Dimension
minimumSize()
{
- return(getMinimumSize(rows));
+ return minimumSize (getRows ());
}
/*************************************************************************/
public Dimension
getMinimumSize(int rows)
{
- ListPeer lp = (ListPeer)getPeer();
- if (lp != null)
- return(lp.minimumSize(rows));
- else
- return(new Dimension(0,0));
+ return minimumSize (rows);
}
/*************************************************************************/
public Dimension
minimumSize(int rows)
{
- return(getMinimumSize(rows));
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.minimumSize (rows);
+ else
+ return new Dimension (0, 0);
}
/*************************************************************************/
public Dimension
getPreferredSize()
{
- return(getPreferredSize(rows));
+ return getPreferredSize (getRows ());
}
/*************************************************************************/
public Dimension
preferredSize()
{
- return(getPreferredSize(rows));
+ return preferredSize (getRows ());
}
/*************************************************************************/
public Dimension
getPreferredSize(int rows)
{
- ListPeer lp = (ListPeer)getPeer();
- if (lp != null)
- return(lp.preferredSize(rows));
- else
- return(new Dimension(0,0));
+ return preferredSize (rows);
}
/*************************************************************************/
public Dimension
preferredSize(int rows)
{
- return(getPreferredSize(rows));
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.preferredSize (rows);
+ else
+ return new Dimension (0, 0);
}
/*************************************************************************/
public void
add(String item)
{
- add(item, -1);
+ add (item, -1);
}
/*************************************************************************/
public void
addItem(String item)
{
- addItem(item, -1);
+ addItem (item, -1);
}
/*************************************************************************/
public void
add(String item, int index)
{
- if ((index == -1) || (index >= items.size()))
- items.addElement(item);
- else
- items.insertElementAt(item, index);
-
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.add (item, index);
- }
+ addItem (item, index);
}
/*************************************************************************/
public void
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);
}
/*************************************************************************/
public void
delItem(int index) throws IllegalArgumentException
{
- remove(index);
+ items.removeElementAt (index);
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.delItems (index, index);
}
/*************************************************************************/
public void
remove(int index) throws IllegalArgumentException
{
- items.removeElementAt (index);
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.delItems (index, index);
- }
+ delItem (index);
}
/*************************************************************************/
public synchronized void
removeAll()
{
- items.clear();
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.removeAll ();
- }
+ clear ();
}
/*************************************************************************/
public void
clear()
{
- removeAll();
+ items.clear();
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.removeAll ();
}
/*************************************************************************/
public boolean
isIndexSelected(int index)
{
- int[] indexes = getSelectedIndexes();
-
- for (int i = 0; i < indexes.length; i++)
- if (indexes[i] == index)
- return(true);
-
- return(false);
+ return isSelected (index);
}
/*************************************************************************/
public boolean
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;
}
/*************************************************************************/
public int
getItemCount()
{
- return(items.size());
+ return countItems ();
}
/**
*/
public int countItems ()
{
- return getItemCount ();
+ return items.size ();
}
/*************************************************************************/
public int
getMenuCount()
{
- // FIXME: How does the help menu fit in here?
- return(menus.size());
+ return countMenus ();
}
/*************************************************************************/
public int
countMenus()
{
- return(getMenuCount());
+ // FIXME: How does the help menu fit in here?
+ return menus.size ();
}
/*************************************************************************/
public synchronized void
setEnabled(boolean enabled)
{
- if (enabled == this.enabled)
- return;
-
- this.enabled = enabled;
- if (peer != null)
- {
- MenuItemPeer mp = (MenuItemPeer) peer;
- mp.setEnabled (enabled);
- }
+ enable (enabled);
}
/*************************************************************************/
public void
enable(boolean enabled)
{
- setEnabled(enabled);
+ if (enabled)
+ enable ();
+ else
+ disable ();
}
/*************************************************************************/
public void
enable()
{
- setEnabled(true);
+ if (enabled)
+ return;
+
+ this.enabled = true;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (true);
}
/*************************************************************************/
public void
disable()
{
- setEnabled(false);
+ if (!enabled)
+ return;
+
+ this.enabled = false;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (false);
}
/*************************************************************************/
* @since 1.1
*/
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 (npoints == 0)
- return bounds = new Rectangle();
+ return bounds = new Rectangle ();
int i = npoints - 1;
int minx = xpoints[i];
int maxx = minx;
else if (y > maxy)
maxy = y;
}
- bounds = new Rectangle(minx, maxy, maxx - minx, maxy - miny);
+ bounds = new Rectangle (minx, maxy, maxx - minx, maxy - miny);
}
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.
*
*/
public void setBounds(Rectangle r)
{
- x = r.x;
- y = r.y;
- width = r.width;
- height = r.height;
+ setBounds (r.x, r.y, r.width, r.height);
}
/**
*/
public void setBounds(int x, int y, int width, int height)
{
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
+ reshape (x, y, width, 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;
}
/**
*/
public void setLocation(Point p)
{
- this.x = p.x;
- this.y = p.y;
+ setLocation (p.x, p.y);
}
/**
*/
public void setLocation(int x, int y)
{
- this.x = x;
- this.y = y;
+ move (x, y);
}
/**
*/
public void move(int x, int y)
{
- setLocation(x, y);
+ this.x = x;
+ this.y = y;
}
/**
*/
public void setSize(Dimension d)
{
- width = d.width;
- height = d.height;
+ setSize (d.width, d.height);
}
/**
*/
public void setSize(int width, int height)
{
- this.width = width;
- this.height = height;
+ resize (width, height);
}
/**
*/
public void resize(int width, int height)
{
- setSize(width, height);
+ this.width = width;
+ this.height = height;
}
/**
*/
public boolean contains(Point p)
{
- return width > 0 && height > 0
- && p.x >= x && p.x < x + width
- && p.y >= y && p.y < y + height;
+ return contains (p.x, p.y);
}
/**
*/
public boolean contains(int x, int y)
{
- return width > 0 && height > 0
- && x >= this.x && x < this.x + width
- && y >= this.y && y < this.y + height;
+ return inside (x, y);
}
/**
*/
public boolean contains(Rectangle r)
{
- return width > 0 && height > 0 && r.width > 0 && r.height > 0
- && r.x >= x && r.x + r.width <= x + width
- && r.y >= y && r.y + r.height <= y + height;
+ return contains (r.x, r.y, r.width, r.height);
}
/**
*/
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;
}
/**
public void
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))
{
- Dimension dim = list[0].getPreferredSize();
+ Dimension dim = list[0].getPreferredSize ();
Dimension vp = getViewportSize ();
if (dim.width < vp.width)
if (peer != null)
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)
p.x = dim.width;
if (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
* manager is set for this container. <code>ScrollPane</code>'s do
public int
getVisibleAmount()
{
- return(visibleAmount);
+ return getVisible ();
}
/*************************************************************************/
public int
getVisible()
{
- return(getVisibleAmount());
+ return visibleAmount;
}
/*************************************************************************/
public int
getUnitIncrement()
{
- return(lineIncrement);
+ return getLineIncrement ();
}
/*************************************************************************/
public int
getLineIncrement()
{
- return(lineIncrement);
+ return lineIncrement;
}
/*************************************************************************/
public synchronized void
setUnitIncrement(int unitIncrement)
{
- if (unitIncrement < 0)
- 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);
+ setLineIncrement (unitIncrement);
}
/*************************************************************************/
public void
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);
}
/*************************************************************************/
public int
getBlockIncrement()
{
- return(pageIncrement);
+ return getPageIncrement ();
}
/*************************************************************************/
public int
getPageIncrement()
{
- return(pageIncrement);
+ return pageIncrement;
}
/*************************************************************************/
public synchronized void
setBlockIncrement(int blockIncrement)
{
- if (blockIncrement < 0)
- 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);
+ setPageIncrement (blockIncrement);
}
/*************************************************************************/
public void
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);
}
/*************************************************************************/
*/
public Dimension getMinimumSize (int rows, int 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);
+ return minimumSize (rows, columns);
}
/**
*/
public Dimension minimumSize ()
{
- return getMinimumSize (getRows (), getColumns ());
+ return minimumSize (getRows (), getColumns ());
}
/**
*/
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);
}
/**
*/
public Dimension getPreferredSize (int rows, int 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);
+ return preferredSize (rows, columns);
}
/**
*/
public Dimension preferredSize ()
{
- return getPreferredSize (getRows (), getColumns ());
+ return preferredSize (getRows (), getColumns ());
}
/**
*/
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);
}
/**
/**
* 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)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
- if (peer == null)
- return;
-
- peer.insert (str, peer.getText().length ());
+ appendText (str);
}
/**
* 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
* <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
* 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.
*/
- public void insert (String text, int pos)
+ public void insert (String str, int pos)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
- if (peer == null)
- return;
-
- peer.insert (text, pos);
+ insertText (str, pos);
}
/**
* Insert the specified text at the specified position. The first
* 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.
*
- * @deprecated This method is depcreated in favor of
+ * @deprecated This method is deprecated in favor of
* <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);
}
/**
* length of the replacement text may differ from the length of the
* 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 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 ();
- if (peer == null)
- return;
-
- peer.replaceRange (text, start, end);
+ replaceText (str, start, end);
}
/**
* length of the replacement text may differ from the length of the
* 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 end The end position of the replacement range.
*
* @deprecated This method is deprecated in favor of
* <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);
}
/**
public void
setEchoChar(char echoChar)
{
- this.echoChar = echoChar;
-
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp != null)
- tfp.setEchoChar(echoChar);
+ setEchoCharacter (echoChar);
}
/*************************************************************************/
public void
setEchoCharacter(char echoChar)
{
- setEchoChar(echoChar);
+ this.echoChar = echoChar;
+
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer != null)
+ peer.setEchoChar (echoChar);
}
/*************************************************************************/
public Dimension
getMinimumSize()
{
- return(getMinimumSize(getColumns()));
+ return getMinimumSize (getColumns ());
}
/*************************************************************************/
public Dimension
getMinimumSize(int columns)
{
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp == null)
- return(null); // FIXME: What do we do if there is no peer?
-
- return(tfp.getMinimumSize(columns));
+ return minimumSize (columns);
}
/*************************************************************************/
*
* @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>.
*/
public Dimension
minimumSize()
{
- return(getMinimumSize(getColumns()));
+ return minimumSize (getColumns ());
}
/*************************************************************************/
public Dimension
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);
}
/*************************************************************************/
public Dimension
getPreferredSize()
{
- return(getPreferredSize(getColumns()));
+ return getPreferredSize (getColumns ());
}
/*************************************************************************/
public Dimension
getPreferredSize(int columns)
{
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp == null)
- {
- return new Dimension(0, 0);
- }
- return(tfp.getPreferredSize(columns));
+ return preferredSize (columns);
}
/*************************************************************************/
public Dimension
preferredSize()
{
- return(getPreferredSize(getColumns()));
+ return preferredSize (getColumns ());
}
/*************************************************************************/
public Dimension
preferredSize(int columns)
{
- return(getPreferredSize(columns));
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getPreferredSize (columns);
}
/*************************************************************************/
public void preConcatenateTransform(AffineTransform pre)
{
- xform.preConcatenate(pre);
+ preConcetenateTransform (pre);
}
- /** @deprecated Sun can't spell concatenate */
+ /** @deprecated */
public void preConcetenateTransform(AffineTransform pre)
{
- preConcetenateTransform(pre);
+ xform.preConcatenate (pre);
}
public void concatenateTransform(AffineTransform post)
{
- xform.concatenate(post);
+ concetenateTransform (post);
}
- /** @deprecated Sun can't spell concatenate */
+ /** @deprecated */
public void concetenateTransform(AffineTransform post)
{
- concatenateTransform(post);
+ xform.concatenate (post);
}
public AffineTransform getTransform()
public Dimension 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;
}