aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/awt')
-rw-r--r--libjava/java/awt/AWTEvent.java12
-rw-r--r--libjava/java/awt/BorderLayout.java12
-rw-r--r--libjava/java/awt/Button.java24
-rw-r--r--libjava/java/awt/Component.java6
-rw-r--r--libjava/java/awt/Container.java5
-rw-r--r--libjava/java/awt/GridBagLayout.java21
-rw-r--r--libjava/java/awt/MediaTracker.java19
-rw-r--r--libjava/java/awt/MenuItem.java5
-rw-r--r--libjava/java/awt/TextArea.java30
-rw-r--r--libjava/java/awt/TextComponent.java1
10 files changed, 98 insertions, 37 deletions
diff --git a/libjava/java/awt/AWTEvent.java b/libjava/java/awt/AWTEvent.java
index a084dcf..675c27f 100644
--- a/libjava/java/awt/AWTEvent.java
+++ b/libjava/java/awt/AWTEvent.java
@@ -238,8 +238,16 @@ public abstract class AWTEvent extends EventObject
*/
public String toString ()
{
- return getClass ().getName () + "[" + paramString () + "] on "
- + ((Component) source).getName ();
+ String string = null;
+
+ if (source instanceof Component)
+ string = getClass ().getName () + "[" + paramString () + "] on "
+ + ((Component) source).getName ();
+ else if (source instanceof MenuComponent)
+ string = getClass ().getName () + "[" + paramString () + "] on "
+ + ((MenuComponent) source).getName ();
+
+ return string;
}
/**
diff --git a/libjava/java/awt/BorderLayout.java b/libjava/java/awt/BorderLayout.java
index 38e4de7..a023cbb 100644
--- a/libjava/java/awt/BorderLayout.java
+++ b/libjava/java/awt/BorderLayout.java
@@ -592,13 +592,21 @@ layoutContainer(Container target)
int x1 = i.left;
int x2 = x1 + w.width + hgap;
- int x3 = Math.max(x2 + w.width + hgap, t.width - i.right - e.width);
+ int x3;
+ if (t.width <= i.right + e.width)
+ x3 = x2 + w.width + hgap;
+ else
+ x3 = t.width - i.right - e.width;
int ww = t.width - i.right - i.left;
int y1 = i.top;
int y2 = y1 + n.height + vgap;
int midh = Math.max(e.height, Math.max(w.height, c.height));
- int y3 = Math.max(y2 + midh + vgap, t.height - i.bottom - s.height);
+ int y3;
+ if (t.height <= i.bottom + s.height)
+ y3 = y2 + midh + vgap;
+ else
+ y3 = t.height - i.bottom - s.height;
int hh = y3-y2-vgap;
setBounds(center, x2, y2, x3-x2-hgap, hh);
diff --git a/libjava/java/awt/Button.java b/libjava/java/awt/Button.java
index a521c8e..54b201e 100644
--- a/libjava/java/awt/Button.java
+++ b/libjava/java/awt/Button.java
@@ -81,6 +81,11 @@ private String label;
// List of ActionListeners for this class.
private transient ActionListener action_listeners;
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_button_number = 0;
+
/*************************************************************************/
/*
@@ -305,9 +310,24 @@ dispatchEventImpl(AWTEvent e)
protected String
paramString()
{
- return ("label=" + getLabel() + ",actionCommand=" + getActionCommand()
- + "," + super.paramString());
+ return getName () + "," + getX () + "," + getY () + ","
+ + getWidth () + "x" + getHeight () + ",label=" + getLabel ();
}
+ /**
+ * Generate a unique name for this button.
+ *
+ * @return A unique name for this button.
+ */
+ String generateName ()
+ {
+ return "button" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_button_number++;
+ }
+
} // class Button
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java
index 3ca2b4f..f3153da 100644
--- a/libjava/java/awt/Component.java
+++ b/libjava/java/awt/Component.java
@@ -941,7 +941,7 @@ public abstract class Component
{
if (foreground != null)
return foreground;
- return parent == null ? null : parent.getForeground();
+ return parent == null ? SystemColor.windowText : parent.getForeground();
}
/**
@@ -982,7 +982,7 @@ public abstract class Component
{
if (background != null)
return background;
- return parent == null ? null : parent.getBackground();
+ return parent == null ? SystemColor.window : parent.getBackground();
}
/**
@@ -1031,7 +1031,7 @@ public abstract class Component
if (parent != null)
return parent.getFont ();
else
- return new Font ("Fixed", Font.PLAIN, 12);
+ return new Font ("Dialog", Font.PLAIN, 12);
}
/**
diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java
index 0482e65..ffd81b4 100644
--- a/libjava/java/awt/Container.java
+++ b/libjava/java/awt/Container.java
@@ -876,11 +876,6 @@ public class Container extends Component
{
return locate (x, y);
}
-
- public Component getComponentAt(int index)
- {
- return component[index];
- }
/**
* Returns the component located at the specified point. This is done
diff --git a/libjava/java/awt/GridBagLayout.java b/libjava/java/awt/GridBagLayout.java
index 301e713..b98359c 100644
--- a/libjava/java/awt/GridBagLayout.java
+++ b/libjava/java/awt/GridBagLayout.java
@@ -790,13 +790,26 @@ public class GridBagLayout
info.rowWeights);
} // end of STEP 4
- calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
- calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+ // Adjust cell sizes iff parent size not zero.
+ if (parentDim.width > 0 && parentDim.height > 0)
+ {
+ 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;
+
+ // Make sure pos_x and pos_y are never negative.
+ if (totalWidth >= parentDim.width)
+ info.pos_x = parentInsets.left;
+ else
+ info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
+
+ if (totalHeight >= parentDim.height)
+ info.pos_y = parentInsets.top;
+ else
+ info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
// DEBUG
//dumpLayoutInfo (info);
diff --git a/libjava/java/awt/MediaTracker.java b/libjava/java/awt/MediaTracker.java
index b115734..d1df8b3 100644
--- a/libjava/java/awt/MediaTracker.java
+++ b/libjava/java/awt/MediaTracker.java
@@ -81,12 +81,17 @@ public class MediaTracker implements java.io.Serializable
status = ERRORED | COMPLETE;
else if ((flags & ALLBITS) != 0)
status = COMPLETE;
- else
+ else if ((flags & SOMEBITS) != 0)
status = LOADING;
-
- synchronized (MediaTracker.this)
+ else
+ status = 0;
+
+ if ((status & COMPLETE) == COMPLETE)
{
- MediaTracker.this.notifyAll();
+ synchronized (MediaTracker.this)
+ {
+ MediaTracker.this.notifyAll();
+ }
}
// If status is not COMPLETE then we need more updates.
return (status & COMPLETE) == 0;
@@ -106,7 +111,8 @@ public class MediaTracker implements java.io.Serializable
e.next = head;
head = e;
// Start tracking image status.
- target.checkImage(image, e);
+ int flags = target.checkImage(image, e);
+ e.imageUpdate(image, flags, -1, -1, -1, -1);
}
public void addImage(Image image, int id, int width, int height)
@@ -119,7 +125,8 @@ public class MediaTracker implements java.io.Serializable
e.height = height;
head = e;
// Start tracking image status.
- target.checkImage(image, width, height, e);
+ int flags = target.checkImage(image, width, height, e);
+ e.imageUpdate(image, flags, -1, -1, width, height);
}
public boolean checkAll()
diff --git a/libjava/java/awt/MenuItem.java b/libjava/java/awt/MenuItem.java
index 4defc38..8511f69 100644
--- a/libjava/java/awt/MenuItem.java
+++ b/libjava/java/awt/MenuItem.java
@@ -424,6 +424,11 @@ dispatchEventImpl(AWTEvent e)
&& (action_listeners != null
|| (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
processEvent(e);
+
+ // Send the event to the parent menu if it has not yet been
+ // consumed.
+ if (!e.isConsumed ())
+ ((Menu) getParent ()).processEvent (e);
}
/**
diff --git a/libjava/java/awt/TextArea.java b/libjava/java/awt/TextArea.java
index f27c296..6355376 100644
--- a/libjava/java/awt/TextArea.java
+++ b/libjava/java/awt/TextArea.java
@@ -103,29 +103,33 @@ public class TextArea extends TextComponent implements java.io.Serializable
private static transient long next_text_number = 0;
/**
- * Initialize a new instance of <code>TextArea</code> that is empty
- * and is one row by one column. Both horizontal and vertical
+ * Initialize a new instance of <code>TextArea</code> that is empty.
+ * Conceptually the <code>TextArea</code> has 0 rows and 0 columns
+ * but its initial bounds are defined by its peer or by the
+ * container in which it is packed. Both horizontal and vertical
* scrollbars will be displayed.
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea ()
{
- this ("", 1, 1, SCROLLBARS_BOTH);
+ this ("", 0, 0, SCROLLBARS_BOTH);
}
/**
- * Initialize a new instance of <code>TextArea</code> that initially
- * contains the specified text. Both horizontal and veritcal
- * scrollbars will be displayed.
+ * Initialize a new instance of <code>TextArea</code> that contains
+ * the specified text. Conceptually the <code>TextArea</code> has 0
+ * rows and 0 columns but its initial bounds are defined by its peer
+ * or by the container in which it is packed. Both horizontal and
+ * veritcal scrollbars will be displayed.
*
* @param text The text to display in this text area.
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text)
{
- this (text, 1, text.length (), SCROLLBARS_BOTH);
+ this (text, 0, 0, SCROLLBARS_BOTH);
}
/**
@@ -137,7 +141,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (int rows, int columns)
{
@@ -154,7 +158,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text, int rows, int columns)
{
@@ -175,7 +179,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY,
* SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE.
*
- * @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text, int rows, int columns, int scrollbarVisibility)
{
@@ -184,7 +188,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
- if (rows < 1 || columns < 0)
+ if (rows < 0 || columns < 0)
throw new IllegalArgumentException ("Bad row or column value");
if (scrollbarVisibility != SCROLLBARS_BOTH
diff --git a/libjava/java/awt/TextComponent.java b/libjava/java/awt/TextComponent.java
index 0a410a4..9cdb507 100644
--- a/libjava/java/awt/TextComponent.java
+++ b/libjava/java/awt/TextComponent.java
@@ -141,6 +141,7 @@ setText(String text)
TextComponentPeer tcp = (TextComponentPeer)getPeer();
if (tcp != null)
tcp.setText(text);
+ setCaretPosition(0);
}
/*************************************************************************/