OSDN Git Service

* java/awt/MenuContainer.java: Fixed typo.
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Dec 2000 00:25:13 +0000 (00:25 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Dec 2000 00:25:13 +0000 (00:25 +0000)
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Added SystemColor.java.
* java/awt/SystemColor.java: New file.

* java/awt/Color.java (rgba): Now package-private.

* java/awt/event/InputEvent.java (isAltGraphDown): New method.

* java/awt/event/ContainerEvent.java (getContainer): Renamed from
getComponent.

* java/awt/MenuItem.java (addNotify): New method.
(MenuItem(String,MenuShortcut)): New constructor.
(setLabel): Notify peer of change.
(setEnabled): Likewise.

* java/awt/GridLayout.java (toString): New method.

* java/awt/FlowLayout.java (LEADING, TRAILING): New constants.
(FlowLayout): Check for LEADING and TRAILING.
(setAlignment): Likewise.
(layoutContainer): Handle component orientation.

* java/awt/Component.java (orientatin): New field.
(setComponentOrientation): Wrote.
(getComponentOrientation): Wrote.

* java/awt/Event.java (Event): Implements Serializable.
(consumed): New field for serialization.
* java/awt/Dimension.java (Dimension): Implements Serializable.
* java/awt/Cursor.java (Cursor): Implements Serializable.
* java/awt/Container.java (Container): No longer abstract.

* java/awt/Choice.java: Wrote.
* java/awt/Checkbox.java: Wrote.
* java/awt/ItemSelectable.java: Documented.
* java/awt/CheckboxGroup.java: Wrote.

* java/awt/CardLayout.java (layoutContainer): Directly use fields
in other classes.
(getSize): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38486 138bc75d-0d04-0410-961f-82ee72b054a4

21 files changed:
libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/java/awt/CardLayout.java
libjava/java/awt/Checkbox.java
libjava/java/awt/CheckboxGroup.java
libjava/java/awt/Choice.java
libjava/java/awt/Color.java
libjava/java/awt/Component.java
libjava/java/awt/Container.java
libjava/java/awt/Cursor.java
libjava/java/awt/Dimension.java
libjava/java/awt/Event.java
libjava/java/awt/FlowLayout.java
libjava/java/awt/GridLayout.java
libjava/java/awt/ItemSelectable.java
libjava/java/awt/MenuContainer.java
libjava/java/awt/MenuItem.java
libjava/java/awt/SystemColor.java [new file with mode: 0644]
libjava/java/awt/event/ContainerEvent.java
libjava/java/awt/event/InputEvent.java

index 0fbd6b9..f7544c2 100644 (file)
@@ -1,3 +1,49 @@
+2000-12-25  Tom Tromey  <tromey@redhat.com>
+
+       * java/awt/MenuContainer.java: Fixed typo.
+
+       * Makefile.in: Rebuilt.
+       * Makefile.am (awt_java_source_files): Added SystemColor.java.
+       * java/awt/SystemColor.java: New file.
+
+       * java/awt/Color.java (rgba): Now package-private.
+
+       * java/awt/event/InputEvent.java (isAltGraphDown): New method.
+
+       * java/awt/event/ContainerEvent.java (getContainer): Renamed from
+       getComponent.
+
+       * java/awt/MenuItem.java (addNotify): New method.
+       (MenuItem(String,MenuShortcut)): New constructor.
+       (setLabel): Notify peer of change.
+       (setEnabled): Likewise.
+
+       * java/awt/GridLayout.java (toString): New method.
+
+       * java/awt/FlowLayout.java (LEADING, TRAILING): New constants.
+       (FlowLayout): Check for LEADING and TRAILING.
+       (setAlignment): Likewise.
+       (layoutContainer): Handle component orientation.
+
+       * java/awt/Component.java (orientatin): New field.
+       (setComponentOrientation): Wrote.
+       (getComponentOrientation): Wrote.
+
+       * java/awt/Event.java (Event): Implements Serializable.
+       (consumed): New field for serialization.
+       * java/awt/Dimension.java (Dimension): Implements Serializable.
+       * java/awt/Cursor.java (Cursor): Implements Serializable.
+       * java/awt/Container.java (Container): No longer abstract.
+
+       * java/awt/Choice.java: Wrote.
+       * java/awt/Checkbox.java: Wrote.
+       * java/awt/ItemSelectable.java: Documented.
+       * java/awt/CheckboxGroup.java: Wrote.
+
+       * java/awt/CardLayout.java (layoutContainer): Directly use fields
+       in other classes.
+       (getSize): Likewise.
+
 2000-12-24  Jeff Sturm  <jeff.sturm@commerceone.com>
 
        * java/io/FileDescriptor.java: Initialize fd to -1.
index acfccb8..f18686e 100644 (file)
@@ -624,6 +624,7 @@ java/awt/RenderingHints.java \
 java/awt/ScrollPane.java \
 java/awt/Scrollbar.java        \
 java/awt/Shape.java \
+java/awt/SystemColor.java \
 java/awt/TextArea.java \
 java/awt/TextComponent.java \
 java/awt/TextField.java        \
index 390c6ef..bc2e06a 100644 (file)
@@ -120,29 +120,43 @@ here = @here@
 libgcj_basedir = @libgcj_basedir@
 
 AUTOMAKE_OPTIONS = foreign no-installinfo
-@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
-@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
-@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
-@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
-@NO_X_TRUE@cond_x_ltlibrary = 
-@NO_X_FALSE@cond_x_ltlibrary = @NO_X_FALSE@libgcjx.la
+@TESTSUBDIR_TRUE@SUBDIRS = \
+@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
+@TESTSUBDIR_FALSE@SUBDIRS = \
+@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
+@USE_LIBDIR_TRUE@toolexeclibdir = \
+@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexeclibdir = \
+@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
+@USE_LIBDIR_FALSE@toolexecdir = \
+@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
+@NO_X_TRUE@cond_x_ltlibrary = \
+@NO_X_FALSE@cond_x_ltlibrary = \
+@NO_X_FALSE@libgcjx.la
 
 toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary)
 toolexeclib_DATA = libgcj.spec
 data_DATA = libgcj.jar
 
-@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
-@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
+@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
+@NEEDS_DATA_START_TRUE@libgcjdata.a
+@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
+@NEEDS_DATA_START_TRUE@libgcjdata.c
 
-@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
+@NATIVE_TRUE@bin_PROGRAMS = \
+@NATIVE_TRUE@jv-convert gij
 
 bin_SCRIPTS = addr2name.awk
-@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
-@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
-@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
-@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
-@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
+@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
+@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
+@CANADIAN_TRUE@@NULL_TARGET_FALSE@fastjar
+@CANADIAN_FALSE@ZIP = \
+@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar$(EXEEXT)
+@CANADIAN_TRUE@GCJH = \
+@CANADIAN_TRUE@gcjh
+@CANADIAN_FALSE@GCJH = \
+@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
 
 GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
 
@@ -159,8 +173,10 @@ AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fasynchronous-exceptions \
        -fdollars-in-identifiers \
        @LIBGCJ_CXXFLAGS@ @EXCEPTIONSPEC@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE
 
-@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
-@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
+@USING_GCC_TRUE@AM_CFLAGS = \
+@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
+@USING_GCC_FALSE@AM_CFLAGS = \
+@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
 
 JCFLAGS = -g
 JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
@@ -229,7 +245,8 @@ extra_headers = java/lang/Object.h java/lang/Class.h
 
 NM = nm
 
-@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
+@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
+@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
 
 CONVERT_DIR = gnu/gcj/convert
 
@@ -376,6 +393,7 @@ java/awt/RenderingHints.java \
 java/awt/ScrollPane.java \
 java/awt/Scrollbar.java        \
 java/awt/Shape.java \
+java/awt/SystemColor.java \
 java/awt/TextArea.java \
 java/awt/TextComponent.java \
 java/awt/TextField.java        \
@@ -1194,7 +1212,7 @@ libgcj-test.spec.in libgcj.spec.in
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 DIST_SUBDIRS =  @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
 DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
@@ -1337,10 +1355,11 @@ DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
 .deps/java/awt/PopupMenu.P .deps/java/awt/Rectangle.P \
 .deps/java/awt/RenderingHints.P .deps/java/awt/ScrollPane.P \
 .deps/java/awt/Scrollbar.P .deps/java/awt/Shape.P \
-.deps/java/awt/TextArea.P .deps/java/awt/TextComponent.P \
-.deps/java/awt/TextField.P .deps/java/awt/Toolkit.P \
-.deps/java/awt/Transparency.P .deps/java/awt/Window.P \
-.deps/java/awt/color/ColorSpace.P .deps/java/awt/color/ICC_ColorSpace.P \
+.deps/java/awt/SystemColor.P .deps/java/awt/TextArea.P \
+.deps/java/awt/TextComponent.P .deps/java/awt/TextField.P \
+.deps/java/awt/Toolkit.P .deps/java/awt/Transparency.P \
+.deps/java/awt/Window.P .deps/java/awt/color/ColorSpace.P \
+.deps/java/awt/color/ICC_ColorSpace.P \
 .deps/java/awt/color/ICC_Profile.P \
 .deps/java/awt/datatransfer/Clipboard.P \
 .deps/java/awt/event/AWTEventListener.P \
@@ -2096,7 +2115,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index eaa722b..05e4a44 100644 (file)
@@ -19,7 +19,7 @@ import java.io.Serializable;
  * time.  This class includes methods for changing which card is
  * shown.
  *
- * @verson 0.0
+ * @version 0.0
  * @author Tom Tromey <tromey@redhat.com>
  * @date December 2, 2000
  */
@@ -127,24 +127,22 @@ public class CardLayout implements LayoutManager2, Serializable
    */
   public void layoutContainer (Container parent)
   {
-    // FIXME: can we just use the width and height fields of parent?
-    // Or will that break with subclassing?
-    Dimension d = parent.getSize ();
+    int width = parent.width;
+    int height = parent.height;
 
     Insets ins = parent.getInsets ();
 
-    int num = parent.getComponentCount ();
-    // This is more efficient than calling getComponents().
+    int num = parent.ncomponents;
     Component[] comps = parent.component;
-    
+
     for (int i = 0; i < num; ++i)
       {
        if (comps[i].isVisible ())
          {
            // Only resize the one we care about.
            comps[i].setBounds (hgap + ins.left, vgap + ins.top,
-                               d.width - 2 * hgap - ins.left - ins.right,
-                               d.height - 2 * vgap - ins.top - ins.bottom);
+                               width - 2 * hgap - ins.left - ins.right,
+                               height - 2 * vgap - ins.top - ins.bottom);
            break;
          }
       }
@@ -302,14 +300,11 @@ public class CardLayout implements LayoutManager2, Serializable
   // Compute the size according to WHAT.
   private Dimension getSize (Container parent, int what)
   {
-    int w = 0, h = 0, num = parent.getComponentCount ();
-    // This is more efficient than calling getComponents().
+    int w = 0, h = 0, num = parent.ncomponents;
     Component[] comps = parent.component;
 
     for (int i = 0; i < num; ++i)
       {
-       // FIXME: can we just directly read the fields in Component?
-       // Or will that not work with subclassing?
        Dimension d;
 
        if (what == MIN)
index ec1f20d..10c6744 100644 (file)
@@ -7,9 +7,179 @@ Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
 details.  */
 
 package java.awt;
+import java.awt.event.*;
+import java.awt.peer.CheckboxPeer;
 
-/* A very incomplete placeholder. */
-
-public class Checkbox extends Component
+/** This class implements a component which has an on/off state.  Two
+ * or more Checkboxes can be grouped by a CheckboxGroup.
+ * @author Tom Tromey <tromey@redhat.com>
+ * @date December 25, 2000
+ */
+public class Checkbox extends Component implements ItemSelectable
 {
+  /** Create a new checkbox.
+   * @param label The checkbox label.  A null value is the same as "";
+   *              this is the default.
+   * @param state The initial check state; defaults to false.
+   * @param group The CheckboxGroup.  Defaults to null.
+   */
+  public Checkbox ()
+  {
+    this (null, null, false);
+  }
+
+  public Checkbox (String label)
+  {
+    this (label, null, false);
+  }
+
+  public Checkbox (String label, boolean state)
+  {
+    this (label, null, state);
+  }
+
+  public Checkbox (String label, boolean state, CheckboxGroup group)
+  {
+    this (label, group, state);
+  }
+
+  public Checkbox (String label, CheckboxGroup group, boolean state)
+  {
+    this.label = label;
+    this.group = group;
+    this.state = state;
+  }
+
+  /** Add a listener for item events.
+   * @param listener The listener to add.
+   */
+  public synchronized void addItemListener (ItemListener listener)
+  {
+    listeners = AWTEventMulticaster.add (listeners, listener);
+  }
+
+  /** This creates the component's peer.  */
+  public void addNotify ()
+  {
+    if (peer == null)
+      peer = getToolkit ().createCheckbox (this);
+  }
+
+  /** Returns the current CheckboxGroup associated with this
+   * Checkbox.  */
+  public CheckboxGroup getCheckboxGroup ()
+  {
+    return group;
+  }
+
+  /** Returns the current label; might be null.  */
+  public String getLabel ()
+  {
+    return label;
+  }
+
+  /** Returns this checkbox's label if this checkbox is selected.  */
+  public Object[] getSelectedObjects ()
+  {
+    Object[] r;
+    if (state)
+      {
+       r = new Object[1];
+       r[0] = label;
+      }
+    else
+      r = new Object[0];
+    return r;
+  }
+
+  /** Returns the current state of this checkbox.  */
+  public boolean getState ()
+  {
+    return state;
+  }
+
+  /** Generates a String representation of this Checkbox's state.  */
+  protected String paramString ()
+  {
+    return ("Checkbox["
+           + "state=" + state + ","
+           + "label=" + label + ","
+           + "group=" + group + "]");
+  }
+
+  /** Process an event for this Checkbox.
+   * @param event The event the process.
+   */
+  protected void processEvent (AWTEvent event) 
+  {
+    if (event instanceof ItemEvent)
+      processItemEvent ((ItemEvent) event);
+    else
+      super.processEvent (event);
+  }
+
+  /** Process an item event for this Checkbox.
+   * @param event The ItemEvent to process
+   */
+  protected void processItemEvent (ItemEvent event)
+  {
+    if (listeners != null)
+      listeners.itemStateChanged (event);
+  }
+
+  /** Remove an item listener.
+   * @param listener Item listener to remove.
+   */
+  public synchronized void removeItemListener (ItemListener listener)
+  {
+    listeners = AWTEventMulticaster.remove (listeners, listener);
+  }
+
+  /** Set this checkbox's group.
+   * @param group The new group.  null means remove the Checkbox from
+   *              its group.
+   */
+  public void setCheckboxGroup (CheckboxGroup group)
+  {
+    this.group = group;
+    if (peer != null)
+      {
+       CheckboxPeer cp = (CheckboxPeer) peer;
+       cp.setCheckboxGroup (group);
+      }
+  }
+
+  /** Set the checkbox's label.
+   * @param label The new label
+   */
+  public synchronized void setLabel (String label)
+  {
+    this.label = label;
+    if (peer != null)
+      {
+       CheckboxPeer cp = (CheckboxPeer) peer;
+       // FIXME: unclear what to do here; we err on the side of
+       // caution.
+       cp.setLabel (label == null ? "" : label);
+      }
+  }
+
+  /** Set the checkbox's state.
+   * @param state The new state.
+   */
+  public void setState (boolean state)
+  {
+    this.state = state;
+    if (peer != null)
+      {
+       CheckboxPeer cp = (CheckboxPeer) peer;
+       cp.setState (state);
+      }
+  }
+
+  private ItemListener listeners;
+
+  String label;
+  CheckboxGroup group;
+  boolean state;
 }
index 0acd7b5..d098a42 100644 (file)
@@ -8,11 +8,59 @@ details.  */
 
 package java.awt;
 
-/* Status: Empty placeholder. */
+import java.io.Serializable;
 
-public class CheckboxGroup
+/** This class is used to groups checkbox components.
+ * @author Tom Tromey <tromey@redhat.com>
+ * @date December 25, 2000
+ */
+public class CheckboxGroup implements Serializable
 {
-  // Fields from the serialization spec. Decalare others "transient".
-  boolean state;
-  int checkboxMenuItemSerializedDataVersion;
+  // Current set checkbox.
+  Checkbox selectedCheckbox;
+
+  /** Create a new instance of CheckboxGroup.  */
+  public CheckboxGroup ()
+  {
+  }
+
+  /** Returns the currently selected checkbox in the group.
+   * @deprecated
+   */
+  public Checkbox getCurrent ()
+  {
+    return getSelectedCheckbox ();
+  }
+
+  /** Returns the currently selected checkbox in the group.  */
+  public Checkbox getSelectedCheckbox ()
+  {
+    return selectedCheckbox;
+  }
+
+  /** Set the selected checkbox.
+   * @deprecated
+   */
+  public synchronized void setCurrent (Checkbox checkbox)
+  {
+    setSelectedCheckbox (checkbox);
+  }
+
+  /** Set the selected checkbox.  */
+  public synchronized void setSelectedCheckbox (Checkbox checkbox)
+  {
+    if (checkbox != null && checkbox.group != this)
+      return;
+
+    selectedCheckbox.setState (false);
+    selectedCheckbox = checkbox;
+    if (checkbox != null)
+      checkbox.setState (true);
+  }
+
+  /** Return String representation of this class and current Checkbox.  */
+  public String toString ()
+  {
+    return "[CheckboxGroup: " + selectedCheckbox + "]";
+  }
 }
index cc1ddc0..3e30ead 100644 (file)
@@ -7,9 +7,269 @@ Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
 details.  */
 
 package java.awt;
+import java.awt.event.*;
+import java.awt.peer.ChoicePeer;
+import java.util.ArrayList;
 
-/* A very incomplete placeholder. */
-
-public class Choice extends Component
+/** This component lets the user choose an item from a list of
+ * Strings.
+ * @author Tom Tromey <tromey@redhat.com>
+ * @date December 25, 2000
+ */
+public class Choice extends Component implements ItemSelectable
 {
+  /** Create a new Choice object.  */
+  public Choice ()
+  {
+    items = new ArrayList ();
+    selected = -1;
+  }
+
+  /** Add a new item to this Choice object.  If the item is the first
+   * item on the list, then it is selected.
+   * @param item The new item; must be non-null.
+   */
+  public synchronized void add (String item)
+  {
+    if (item == null)
+      throw new IllegalArgumentException ("item must be non-null");
+    items.add (item);
+
+    int i = items.size () - 1;
+    if (peer != null)
+      {
+       ChoicePeer cp = (ChoicePeer) peer;
+       cp.add (item, i);
+      }
+
+    if (i == 0)
+      select (0);
+  }
+
+  /** Add a new item to this Choice object.  This is the same as the
+   * add method.  */
+  public void addItem (String item)
+  {
+    add (item);
+  }
+
+  /** Add a listener for item events.
+   * @param listener The listener to add.
+   */
+  public synchronized void addItemListener (ItemListener listener)
+  {
+    listeners = AWTEventMulticaster.add (listeners, listener);
+  }
+
+  /** This creates the component's peer.  */
+  public void addNotify ()
+  {
+    if (peer == null)
+      peer = getToolkit ().createChoice (this);
+  }
+
+  /** Returns number of items.
+   * @deprecated
+   */
+  public int countItems ()
+  {
+    return getItemCount ();
+  }
+
+  /** Returns an item from this choice.
+   * @param index Index of the item.  Indices start at zero.
+   */
+  public String getItem (int index)
+  {
+    return (String) items.get (index);
+  }
+
+  /** Returns number of items in Choice.  */
+  public int getItemCount ()
+  {
+    return items.size ();
+  }
+
+  /** Returns index of selected item; -1 if no item is selected.  */
+  public int getSelectedIndex ()
+  {
+    return selected;
+  }
+
+  /** Returns currently selected item; null if no item is selected.  */
+  public synchronized String getSelectedItem ()
+  {
+    return selected == -1 ? null : (String) items.get (selected);
+  }
+
+  /** Returns the currently selected item.  */
+  public synchronized Object[] getSelectedObjects ()
+  {
+    // The JCL says this can return null but that breaks the contract
+    // for ItemSelectable.
+    Object[] r;
+    if (selected != -1)
+      {
+       r = new Object[1];
+       r[0] = items.get (selected);
+      }
+    else
+      r = new Object[0];
+    return r;
+  }
+
+  /** Inserts an item into this Choice.  Existing items are shifted
+   * upwards.  If the new item is the only item, then it is selected.
+   * If the currently selected item is shifted, then the first item is
+   * selected.  If the currently selected item is not shifted, then it
+   * remains selected.
+   * @param item The new item
+   * @param index The position at which to insert it.
+   */
+  public synchronized void insert (String item, int index)
+  {
+    if (index > items.size ())
+      index = items.size ();
+    items.add (index, item);
+
+    if (peer != null)
+      {
+       ChoicePeer cp = (ChoicePeer) peer;
+       cp.add (item, index);
+      }
+
+    if (items.size () == 1 || selected >= index)
+      select (0);
+  }
+
+  /** Generates a String representation of this Choice's state.  */
+  protected String paramString ()
+  {
+    return ("Choice["
+           + "selected=" + selected
+           + "]");
+  }
+
+  /** Process an event for this Choice
+   * @param event The event the process.
+   */
+  protected void processEvent (AWTEvent event)
+  {
+    if (event instanceof ItemEvent)
+      processItemEvent ((ItemEvent) event);
+    else
+      super.processEvent (event);
+  }
+
+  /** Process an item event for this Choice.
+   * @param event The ItemEvent to process
+   */
+  protected void processItemEvent (ItemEvent event)
+  {
+    if (listeners != null)
+      listeners.itemStateChanged (event);
+  }
+
+  /** Remove an item from this Choice.  If several matches exist, the
+   * first one is removed.  If the removed item is selected, the the
+   * first item is selected.
+   * @param item The item string.
+   */
+  public synchronized void remove (String item)
+  {
+    int size = items.size ();
+    for (int i = 0; i < size; ++i)
+      {
+       if (item.equals (items.get (i)))
+         {
+           remove (i);
+           break;
+         }
+      }
+    throw new IllegalArgumentException ("item \"" + item + "\" not in Choice");
+  }
+
+  /** Remove an item from this Choice.  If the removed item is
+   * selected, the the first item is selected.
+   * @param index Index of the item to remove
+   */
+  public synchronized void remove (int index)
+  {
+    items.remove (index);
+
+    if (peer != null)
+      {
+       ChoicePeer cp = (ChoicePeer) peer;
+       cp.remove (index);
+      }
+
+    if (index == selected)
+      select (0);
+    else if (selected > index)
+      --selected;
+  }
+
+  /** Remove all items from this choice.  */
+  public synchronized void removeAll ()
+  {
+    int oldsize = items.size ();
+    items.clear ();
+    selected = -1;
+
+    if (peer != null)
+      {
+       ChoicePeer cp = (ChoicePeer) peer;
+       for (int i = 0; i < oldsize; ++i)
+         {
+           // Always remove item 0.
+           cp.remove (0);
+         }
+      }
+  }
+
+  /** Remove an item listener.
+   * @param listener Item listener to remove.
+   */
+  public synchronized void removeItemListener (ItemListener listener)
+  {
+    listeners = AWTEventMulticaster.remove (listeners, listener);
+  }
+
+  /** Select an item in this Choice.
+   * @param item Name of the item to select.
+   */
+  public synchronized void select (String item)
+  {
+    int size = items.size ();
+    for (int i = 0; i < size; ++i)
+      {
+       if (item.equals (items.get (i)))
+         {
+           select (i);
+           break;
+         }
+      }
+  }
+
+  /** Select an item in this choice.
+   * @param index Index of item to select.
+   */
+  public synchronized void select (int index)
+  {
+    if (index < 0 || index > items.size ())
+      throw new IllegalArgumentException ("index out of range");
+    selected = index;
+    if (peer != null)
+      {
+       ChoicePeer cp = (ChoicePeer) peer;
+       cp.select (index);
+      }
+  }
+
+  private ItemListener listeners;
+
+  // List of items.
+  ArrayList items;
+  // Index of selected item.
+  int selected;
 }
index 6225767..6ae4621 100644 (file)
@@ -38,7 +38,7 @@ public class Color extends Object implements Paint, java.io.Serializable
   // The internal sRGB representation.
   // Alpha is bits 24-31, if hasalpha is true.
   // Red is bits 16-23; Green is bits 8-15; Blue is bits 0-7.
-  private int rgba = 0xFFFFFFFF;
+  int rgba = 0xFFFFFFFF;
 
   public Color(int rgb)
   {
index 09b7244..da5106e 100644 (file)
@@ -90,6 +90,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
   transient HierarchyListener hierarchyListener;
   transient HierarchyBoundsListener hierarchyBoundsListener;
 
+  transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;
+
   protected Component()
   {
   }
@@ -1569,15 +1571,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
   
   public void setComponentOrientation(ComponentOrientation o)
   {
-    // FIXME
+    orientation = o;
   }
-  
+
   public ComponentOrientation getComponentOrientation()
   {
-    // FIXME
-    return null;
+    return orientation;
   }
-  
+
   /*
   public AccessibleContext getAccessibleContext()
   {
index 0cb60ba..aa16a8f 100644 (file)
@@ -18,7 +18,7 @@ import java.awt.peer.LightweightPeer;
 
 /* A somewhat incomplete class. */
 
-public abstract class Container extends Component
+public class Container extends Component
 {
   /* Serialized fields from the serialization spec. */
   int ncomponents;
index 96d36e7..e964a12 100644 (file)
@@ -10,7 +10,7 @@ package java.awt;
 
 /* A somewhat incomplete placeholder. */
 
-public class Cursor
+public class Cursor implements java.io.Serializable
 {
   public static final int DEFAULT_CURSOR   = 0,
                          CROSSHAIR_CURSOR = 1,
index 38ba327..60341cd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999  Free Software Foundation
+/* Copyright (C) 1999, 2000  Free Software Foundation
 
    This file is part of libjava.
 
@@ -20,6 +20,7 @@ package java.awt;
  */
 
 public class Dimension extends java.awt.geom.Dimension2D
+  implements java.io.Serializable
 {
   public int height;
   public int width;
index f1f81c1..481f5b8 100644 (file)
@@ -14,7 +14,7 @@ package java.awt;
  * Status:  Believed complete and correct.
  */
 
-public class Event
+public class Event implements java.io.Serializable
 {
   public static final int SHIFT_MASK = 1,
                          CTRL_MASK = 2,
@@ -82,9 +82,10 @@ public class Event
                          WINDOW_ICONIFY = 203,
                          WINDOW_MOVED = 205;
 
-  public Event evt;
   public Object arg;
   public int clickCount;
+  boolean consumed;            // Required by serialization spec.
+  public Event evt;
   public int id;
   public int key; 
   public int modifiers;
index c74d802..95cb6e6 100644 (file)
@@ -27,6 +27,13 @@ public class FlowLayout implements LayoutManager, Serializable
   /** Constant that specifies right alignment.  */
   public static final int RIGHT = 2;
 
+  /** Constant that specifies alignment to leading edge of container's
+   * orientation.  */
+  public static final int LEADING = 3;
+  /** Constant that specifies alignment to trailing edge of container's
+   * orientation.  */
+  public static final int TRAILING = 4;
+
   /** Add a new component to the layout.  This particular implementation
    * does nothing.
    */
@@ -82,7 +89,8 @@ public class FlowLayout implements LayoutManager, Serializable
       throw new IllegalArgumentException ("horizontal gap must be nonnegative");
     if (vgap < 0)
       throw new IllegalArgumentException ("vertical gap must be nonnegative");
-    if (align != LEFT && align != RIGHT && align != CENTER)
+    if (align != LEFT && align != RIGHT && align != CENTER
+       && align != LEADING && align != TRAILING)
       throw new IllegalArgumentException ("invalid align: " + align);
     this.align = align;
     this.hgap = hgap;
@@ -101,6 +109,9 @@ public class FlowLayout implements LayoutManager, Serializable
     Dimension d = parent.getSize ();
     Insets ins = parent.getInsets ();
 
+    ComponentOrientation orient = parent.getComponentOrientation ();
+    boolean left_to_right = orient.isLeftToRight ();
+
     int y = ins.top + vgap;
     int i = 0;
     while (i < num)
@@ -128,12 +139,20 @@ public class FlowLayout implements LayoutManager, Serializable
 
        // Set the location of each component for this row.
        int x;
-       if (align == LEFT)
+
+       int myalign = align;
+       if (align == LEADING)
+         myalign = left_to_right ? LEFT : RIGHT;
+       else if (align == TRAILING)
+         myalign = left_to_right ? RIGHT : LEFT;
+
+       if (myalign == LEFT)
          x = ins.left + hgap;
-       else if (align == CENTER)
+       else if (myalign == CENTER)
          x = (d.width - new_w) / 2;
        else
          x = d.width - new_w;
+
        for (int k = i; i < j; ++k)
          {
            // FIXME: this is very inefficient.
@@ -178,7 +197,8 @@ public class FlowLayout implements LayoutManager, Serializable
    */
   public void setAlignment (int align)
   {
-    if (align != LEFT && align != RIGHT && align != CENTER)
+    if (align != LEFT && align != RIGHT && align != CENTER
+       && align != LEADING && align != TRAILING)
       throw new IllegalArgumentException ("invalid align: " + align);
     this.align = align;
   }
index f71e4d2..976e384 100644 (file)
@@ -224,6 +224,15 @@ public class GridLayout implements LayoutManager, Serializable
     this.vgap = vgap;
   }
 
+  /** Return String description of this object.  */
+  public String toString ()
+  {
+    return ("[" + getClass ().getName ()
+           + ",hgap=" + hgap + ",vgap=" + vgap
+           + ",rows=" + rows + ",cols=" + cols
+           + "]");
+  }
+
   // This method is used to compute the various sizes.
   private Dimension getSize (Container parent, boolean is_min)
   {
index f51bb33..12d41b7 100644 (file)
@@ -9,16 +9,28 @@ details.  */
 package java.awt;
 import java.awt.event.*;
 
-/**
+/** This interface is implemented by components that support the
+ * select of items.  For instance, Checkbox implements this
+ * interface.
  * @author Tom Tromey <tromey@cygnus.com>
  * @date April 8, 2000
  */
-
-/* Status: Believed complete and correct to JDK 1.2.  */
-
 public interface ItemSelectable
 {
+  /** This method adds a listener to receive item events fired by the
+   * component.
+   * @param l The item listener to add.
+   */
   public void addItemListener (ItemListener l);
+
+  /** This method returns the items in this component which are
+   * currently selected.
+   * @returns A non-null array containing the items.
+   */
   public Object[] getSelectedObjects ();
+
+  /** This method removes an item listener.
+   * @param l The item listener to remove.
+   */
   public void removeItemListener (ItemListener l);
 }
index 295e240..074a00d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999  Free Software Foundation
+/* Copyright (C) 1999, 2000  Free Software Foundation
 
    This file is part of libjava.
 
@@ -13,12 +13,12 @@ package java.awt;
  * Status:  Believed complete and correct.
  */
 
-public  interface MenuContainer
+public interface MenuContainer
 {
   public Font getFont();
 
   /**
-   * @deprected
+   * @deprecated
    */
   public boolean postEvent(Event evt);
 
index 6e79ca0..06b5acc 100644 (file)
@@ -9,8 +9,7 @@ details.  */
 package java.awt;
 import java.awt.event.*;
 import java.util.EventListener;
-
-/* A very incomplete placeholder. */
+import java.awt.peer.MenuItemPeer;
 
 public class MenuItem extends MenuComponent
 {
@@ -34,6 +33,12 @@ public class MenuItem extends MenuComponent
     this.label = label;
   }
 
+  public MenuItem (String label, MenuShortcut shortcut)
+  {
+    this.label = label;
+    this.shortcut = shortcut;
+  }
+
   public String getLabel()
   {
     return label;
@@ -42,6 +47,11 @@ public class MenuItem extends MenuComponent
   public synchronized void setLabel(String label)
   {
     this.label = label;
+    if (peer != null)
+      {
+       MenuItemPeer mp = (MenuItemPeer) peer;
+       mp.setLabel (label);
+      }
   }
 
   public boolean isEnabled()
@@ -51,7 +61,18 @@ public class MenuItem extends MenuComponent
 
   public synchronized void setEnabled(boolean b)
   {
-    this.enabled = b;
+    // The JCL says this method is ignored if the enabled state does
+    // not change.  I take that to mean that the peer is not notified
+    // in this case.
+    if (this.enabled != b)
+      {
+       this.enabled = b;
+       if (peer != null)
+         {
+           MenuItemPeer mp = (MenuItemPeer) peer;
+           mp.setEnabled (b);
+         }
+      }
   }
 
   /** @deprecated Use setEnabled() instead. */
@@ -120,6 +141,16 @@ public class MenuItem extends MenuComponent
     actionListener = AWTEventMulticaster.remove(actionListener, l);
   }
 
+  public void addNotify ()
+  {
+    if (peer != null)
+      {
+       // This choice of toolkit seems unsatisfying, but I'm not sure
+       // what else to do.
+       peer = Toolkit.getDefaultToolkit ().createMenuItem (this);
+      }
+  }
+
   /** Returns all registered EventListers of the given listenerType. 
     * listenerType must be a subclass of EventListener, or a 
     * ClassClassException is thrown.
diff --git a/libjava/java/awt/SystemColor.java b/libjava/java/awt/SystemColor.java
new file mode 100644 (file)
index 0000000..0a77d05
--- /dev/null
@@ -0,0 +1,158 @@
+/* Copyright (C) 2000  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+package java.awt;
+
+/** This class contains most of the colors used by the native
+ * windowing sytem to draw native components.
+ * @author Tom Tromey <tromey@redhat.com>
+ * @date December 25, 2000
+ */
+public final class SystemColor extends Color implements java.io.Serializable
+{
+  /** The background color for the title bar of an active window.  */
+  public static final SystemColor activeCaption
+      = new SystemColor (ACTIVE_CAPTION);
+  /** The border color of an active window.  */
+  public static final SystemColor activeCaptionBorder
+      = new SystemColor (ACTIVE_CAPTION_BORDER);
+  /** The color of text in the title bar of an active window.  */
+  public static final SystemColor activeCaptionText
+      = new SystemColor (ACTIVE_CAPTION_TEXT);
+  /** The background color.  */
+  public static final SystemColor control = new SystemColor (CONTROL);
+  /** The darkest color of an outline.  */
+  public static final SystemColor controlDkShadow
+      = new SystemColor (CONTROL_DK_SHADOW);
+  /** The second brightest color of an outline.  */
+  public static final SystemColor controlHighlight
+      = new SystemColor (CONTROL_HIGHLIGHT);
+  /** The brightest color of an outline.  */
+  public static final SystemColor controlLtHighlight
+      = new SystemColor (CONTROL_LT_HIGHLIGHT);
+  /** The second darkest color of an outline.  */
+  public static final SystemColor controlShadow
+      = new SystemColor (CONTROL_SHADOW);
+  /** The color of text in a label.  */
+  public static final SystemColor controlText = new SystemColor (CONTROL_TEXT);
+  /** The background color of the desktop.  */
+  public static final SystemColor desktop = new SystemColor (DESKTOP);
+  /** The background color for the title bar of an inactive window.  */
+  public static final SystemColor inactiveCaption
+      = new SystemColor (INACTIVE_CAPTION);
+  /** The border color of an inactive window.  */
+  public static final SystemColor inactiveCaptionBorder
+      = new SystemColor (INACTIVE_CAPTION_BORDER);
+  /** The color of text in the title ar of an inactive window.  */
+  public static final SystemColor inactiveCaptionText
+      = new SystemColor (INACTIVE_CAPTION_TEXT);
+  /** The background color of tooltips. */
+  public static final SystemColor info = new SystemColor (INFO);
+  /** The color of text in tooltips.  */
+  public static final SystemColor infoText = new SystemColor (INFO_TEXT);
+  /** The background color of a menu.  */
+  public static final SystemColor menu = new SystemColor (MENU);
+  /** The color of text in a menu.  */
+  public static final SystemColor menuText = new SystemColor (MENU_TEXT);
+  /** The background color of a scrollbar.  */
+  public static final SystemColor scrollbar = new SystemColor (SCROLLBAR);
+  /** The background color of text components.  */
+  public static final SystemColor text = new SystemColor (TEXT);
+  /** The background color of highlighted text.  */
+  public static final SystemColor textHighlight
+      = new SystemColor (TEXT_HIGHLIGHT);
+  /** The color of highlighted text.  */
+  public static final SystemColor textHighlightText
+      = new SystemColor (TEXT_HIGHLIGHT_TEXT);
+  /** The color of inactive text.  */
+  public static final SystemColor textInactiveText
+      = new SystemColor (TEXT_INACTIVE_TEXT);
+  /** The color of text in text components.  */
+  public static final SystemColor textText = new SystemColor (TEXT_TEXT);
+  /** The background color of a window.  */
+  public static final SystemColor window = new SystemColor (WINDOW);
+  /** The border color of a window.  */
+  public static final SystemColor windowBorder
+      = new SystemColor (WINDOW_BORDER);
+  /** The color of text in a window.  */
+  public static final SystemColor windowText = new SystemColor (WINDOW_TEXT);
+
+  public static final int DESKTOP = 0;
+  public static final int ACTIVE_CAPTION = 1;
+  public static final int ACTIVE_CAPTION_TEXT = 2;
+  public static final int ACTIVE_CAPTION_BORDER = 3;
+  public static final int INACTIVE_CAPTION = 4;
+  public static final int INACTIVE_CAPTION_TEXT = 5;
+  public static final int INACTIVE_CAPTION_BORDER = 6;
+  public static final int WINDOW = 7;
+  public static final int WINDOW_BORDER = 8;
+  public static final int WINDOW_TEXT = 9;
+  public static final int MENU = 10;
+  public static final int MENU_TEXT = 11;
+  public static final int TEXT = 12;
+  public static final int TEXT_TEXT = 13;
+  public static final int TEXT_HIGHLIGHT = 14;
+  public static final int TEXT_HIGHLIGHT_TEXT = 15;
+  public static final int TEXT_INACTIVE_TEXT = 16;
+  public static final int CONTROL = 17;
+  public static final int CONTROL_TEXT = 18;
+  public static final int CONTROL_HIGHLIGHT = 19;
+  public static final int CONTROL_LT_HIGHLIGHT = 20;
+  public static final int CONTROL_SHADOW = 21;
+  public static final int CONTROL_DK_SHADOW = 22;
+  public static final int SCROLLBAR = 23;
+  public static final int INFO = 24;
+  public static final int INFO_TEXT = 25;
+
+  public static final int NUM_COLORS = 26;
+
+  private static final int rgbs[] =
+  {
+    0x005c5c,
+    0x000080,
+    0xffffff,
+    0xc0c0c0,
+    0x808080,
+    0xc0c0c0,
+    0xc0c0c0,
+    0xffffff,
+    0x000000,
+    0x000000,
+    0xc0c0c0,
+    0x000000,
+    0xc0c0c0,
+    0x000000,
+    0x000080,
+    0xffffff,
+    0x808080,
+    0xc0c0c0,
+    0x000000,
+    0xffffff,
+    0xe0e0e0,
+    0x808080,
+    0x000000,
+    0xe0e0e0,
+    0xe0e000,
+    0x000000
+  };
+
+  public int getRGB ()
+  {
+    return rgbs[rgba];
+  }
+
+  public String toString ()
+  {
+    return "[" + getClass ().getName () + " " + rgba + "]";
+  }
+
+  private SystemColor (int index)
+  {
+    super (index, true);
+  }
+}
index fc68d14..9e89519 100644 (file)
@@ -35,7 +35,7 @@ public class ContainerEvent extends ComponentEvent
     return child;
   }
 
-  public Component getComponent ()
+  public Component getContainer ()
   {
     return (Component) source;
   }
index 2da7922..e9a11b9 100644 (file)
@@ -47,6 +47,11 @@ public abstract class InputEvent extends ComponentEvent
     return (modifiers & ALT_MASK) != 0;
   }
 
+  public boolean isAltGraphDown ()
+  {
+    return (modifiers & ALT_GRAPH_MASK) != 0;
+  }
+
   public long getWhen ()
   {
     return when;