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]

[PATCH] More List fixes [REPOST]


This is the best I can do without interface changes, reflection etc.
It appears to behave pretty much the same as Sun's now.

2003-12-18 Fernando Nasser <fnasser@redhat.com>

        * java/awt/List.java (replaceItem): Prevent selection to move with
        replace and minimize flickering.
Index: java/awt/List.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/List.java,v
retrieving revision 1.15
diff -c -p -r1.15 List.java
*** java/awt/List.java	2 Dec 2003 16:19:28 -0000	1.15
--- java/awt/List.java	18 Dec 2003 16:28:59 -0000
*************** clear()
*** 647,654 ****
  public synchronized void
  replaceItem(String item, int index) throws IllegalArgumentException
  {
!   remove(index);
!   addItem(item, index);
  }
  
  /*************************************************************************/
--- 647,667 ----
  public synchronized void
  replaceItem(String item, int index) throws IllegalArgumentException
  {
!   if ((index < 0) || (index >= items.size()))
!     throw new IllegalArgumentException("Bad list index: " + index);
! 
!   items.insertElementAt(item, index + 1);
!   items.removeElementAt (index);
! 
!   if (peer != null)
!     {
!       ListPeer l = (ListPeer) peer;
! 
!       /* We add first and then remove so that the selected
! 	 item remains the same */
!       l.add (item, index + 1);
!       l.delItems (index, index);
!     }
  }
  
  /*************************************************************************/

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