This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI [gui]: Remerge Choice with GNU Classpath


Hi,

This merges a small fix for Choice from GNU Classpath:

2004-11-06  Noa Resare  <noa@resare.com>

        * java/awt/Choice.java (add):
        Implement correct selection behavior when peer == null.
        (insert): Likewise.
        (remove): Likewise.

2004-11-06  Mark Wielaard  <mark@klomp.org>

        * gnu/java/awt/peer/gtk/GtkChoicePeer.java (GtkChoicePeer):
        Call select() when Choice has a selected item.

Committed to the gui branch.

Mark
Index: java/awt/Choice.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Choice.java,v
retrieving revision 1.15
diff -u -r1.15 Choice.java
--- java/awt/Choice.java	3 Feb 2004 17:17:29 -0000	1.15
+++ java/awt/Choice.java	25 Oct 2004 11:09:57 -0000
@@ -1,5 +1,5 @@
 /* Choice.java -- Java choice button widget.
-   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -169,6 +169,8 @@
       ChoicePeer cp = (ChoicePeer) peer;
       cp.add (item, i);
     }
+  else if (selectedIndex == -1) 
+    select(0);
 }
 
 /*************************************************************************/
@@ -218,6 +220,8 @@
       ChoicePeer cp = (ChoicePeer) peer;
       cp.add (item, index);
     }
+  else if (selectedIndex == -1 || selectedIndex >= index)
+    select(0);
 }
 
 /*************************************************************************/
@@ -261,6 +265,13 @@
       ChoicePeer cp = (ChoicePeer) peer;
       cp.remove (index);
     }
+  else
+    {
+      if (getItemCount() == 0)
+	selectedIndex = -1;
+      else if (index == selectedIndex)
+	select(0);
+    }
 
   if (selectedIndex > index)
     --selectedIndex;
Index: gnu/java/awt/peer/gtk/GtkChoicePeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java,v
retrieving revision 1.17
diff -u -r1.17 GtkChoicePeer.java
--- gnu/java/awt/peer/gtk/GtkChoicePeer.java	31 Jul 2004 21:15:06 -0000	1.17
+++ gnu/java/awt/peer/gtk/GtkChoicePeer.java	25 Oct 2004 11:09:57 -0000
@@ -59,6 +59,10 @@
 	  
 	append (items);
       }
+
+    int selected = c.getSelectedIndex();
+    if (selected >= 0)
+      select(selected);
   }
 
   native void create ();

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]