commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] classpath ChangeLog javax/swing/JMenu.java


From: Tania Bento
Subject: [commit-cp] classpath ChangeLog javax/swing/JMenu.java
Date: Wed, 21 Jun 2006 14:55:03 +0000

CVSROOT:        /cvsroot/classpath
Module name:    classpath
Changes by:     Tania Bento <tbento>    06/06/21 14:55:03

Modified files:
        .              : ChangeLog 
        javax/swing    : JMenu.java 

Log message:
                2006-06-21  Tania Bento  <address@hidden>
        
                * javax/swing/JMenu.java
                (JMenu): Delay should be set to 200, not default of 0.
                (JMenu): Delay should be set to 200, not default of 0.
                (JMenu): Delay should be set to 200, not default of 0.
                (JMenu): Delay should be set to 200, not default of 0.
                (remove): Added check that index >= 0 before removing
                the component.
                (getItem): Return null if item count equals 0.
                (isTearOff): Should throw new error and not return false.
                (getMenuComponent): Return null if popupMenu is null or
                if there are no menu components.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7900&r2=1.7901
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/JMenu.java?cvsroot=classpath&r1=1.27&r2=1.28

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.7900
retrieving revision 1.7901
diff -u -b -r1.7900 -r1.7901
--- ChangeLog   21 Jun 2006 13:50:58 -0000      1.7900
+++ ChangeLog   21 Jun 2006 14:55:00 -0000      1.7901
@@ -1,3 +1,17 @@
+2006-06-21  Tania Bento  <address@hidden>
+
+       * javax/swing/JMenu.java
+       (JMenu): Delay should be set to 200, not default of 0.
+       (JMenu): Delay should be set to 200, not default of 0.
+       (JMenu): Delay should be set to 200, not default of 0.
+       (JMenu): Delay should be set to 200, not default of 0.  
+       (remove): Added check that index >= 0 before removing
+       the component.
+       (getItem): Return null if item count equals 0.
+       (isTearOff): Should throw new error and not return false.
+       (getMenuComponent): Return null if popupMenu is null or
+       if there are no menu components.
+
 2006-06-21  Roman Kennke  <address@hidden>
 
        * java/awt/font/FontRenderContext.java:
@@ -142,6 +156,7 @@
        * java/net/URL.java (URL): Throw MalformedURLException if a
        RuntimeException is caught.  Chain exceptions.
 
+>>>>>>> 1.7898
 2006-06-20  Lillian Angel  <address@hidden>
 
        * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java

Index: javax/swing/JMenu.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenu.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- javax/swing/JMenu.java      16 May 2006 06:49:32 -0000      1.27
+++ javax/swing/JMenu.java      21 Jun 2006 14:55:03 -0000      1.28
@@ -40,6 +40,7 @@
 
 import java.awt.Component;
 import java.awt.Point;
+import java.awt.PopupMenu;
 import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
@@ -74,7 +75,7 @@
   private static final long serialVersionUID = 4227225638931828014L;
 
   /** A Popup menu associated with this menu, which pops up when menu is 
selected */
-  private JPopupMenu popupMenu = new JPopupMenu();
+  private JPopupMenu popupMenu = null;
 
   /** Whenever menu is selected or deselected the MenuEvent is fired to
      menu's registered listeners. */
@@ -98,6 +99,7 @@
   {
     super();
     setOpaque(false);
+    setDelay(200);
   }
 
   /**
@@ -108,8 +110,10 @@
   public JMenu(String text)
   {
     super(text);
+    popupMenu = new JPopupMenu(); 
     popupMenu.setInvoker(this);
     setOpaque(false);
+    setDelay(200);
   }
 
   /**
@@ -122,8 +126,10 @@
   {
     super(action);
     createActionChangeListener(this);
+    popupMenu = new JPopupMenu();
     popupMenu.setInvoker(this);
     setOpaque(false);
+    setDelay(200);
   }
 
   /**
@@ -137,6 +143,7 @@
   {
     // FIXME: tearoff not implemented
     this(text);
+    setDelay(200);
   }
 
   /**
@@ -148,7 +155,7 @@
    */
   public JMenuItem add(JMenuItem item)
   {
-    return popupMenu.add(item);
+    return getPopupMenu().add(item);
   }
 
   /**
@@ -160,7 +167,7 @@
    */
   public Component add(Component component)
   {
-    popupMenu.insert(component, -1);
+    getPopupMenu().insert(component, -1);
     return component;
   }
 
@@ -174,7 +181,7 @@
    */
   public Component add(Component component, int index)
   {
-    return popupMenu.add(component, index);
+    return getPopupMenu().add(component, index);
   }
 
   /**
@@ -186,7 +193,7 @@
    */
   public JMenuItem add(String text)
   {
-    return popupMenu.add(text);
+    return getPopupMenu().add(text);
   }
 
   /**
@@ -198,7 +205,7 @@
    */
   public JMenuItem add(Action action)
   {
-    return popupMenu.add(action);
+    return getPopupMenu().add(action);
   }
 
   /**
@@ -209,7 +216,7 @@
    */
   public void remove(JMenuItem item)
   {
-    popupMenu.remove(item);
+    getPopupMenu().remove(item);
   }
 
   /**
@@ -219,6 +226,10 @@
    */
   public void remove(int index)
   {
+    if (index < 0 || (index > 0 && getMenuComponentCount() == 0))
+      throw new IllegalArgumentException();
+  
+    if (getMenuComponentCount() > 0)
     popupMenu.remove(index);
   }
 
@@ -229,8 +240,9 @@
    */
   public void remove(Component component)
   {
-    int index = popupMenu.getComponentIndex(component);
-    popupMenu.remove(index);
+    int index = getPopupMenu().getComponentIndex(component);
+    if (index >= 0)
+      getPopupMenu().remove(index);
   }
 
   /**
@@ -267,7 +279,7 @@
     if (index < 0)
       throw new IllegalArgumentException("index less than zero");
 
-    popupMenu.insert(item, index);
+    getPopupMenu().insert(item, index);
     return item;
   }
 
@@ -381,7 +393,7 @@
        super.setSelected(false);
        super.setArmed(false);
        fireMenuDeselected();
-       popupMenu.setVisible(false);
+        getPopupMenu().setVisible(false);
       }
   }
 
@@ -404,7 +416,7 @@
    */
   public boolean isPopupMenuVisible()
   {
-    return popupMenu.isVisible();
+    return getPopupMenu().isVisible();
   }
 
   /**
@@ -415,7 +427,7 @@
   public void setPopupMenuVisible(boolean popup)
   {
     if (getModel().isEnabled())
-      popupMenu.setVisible(popup);
+      getPopupMenu().setVisible(popup);
   }
 
   /**
@@ -530,6 +542,9 @@
     if (index < 0)
       throw new IllegalArgumentException("index less than 0");
 
+    if (getItemCount() == 0)
+      return null;
+    
     Component c = popupMenu.getComponentAtIndex(index);
 
     if (c instanceof JMenuItem)
@@ -558,7 +573,7 @@
   public boolean isTearOff()
   {
     // NOT YET IMPLEMENTED 
-    return false;
+    throw new Error("The method isTearOff() has not yet been implemented.");
   }
 
   /**
@@ -568,7 +583,7 @@
    */
   public int getMenuComponentCount()
   {
-    return popupMenu.getComponentCount();
+    return getPopupMenu().getComponentCount();
   }
 
   /**
@@ -581,6 +596,9 @@
    */
   public Component getMenuComponent(int index)
   {
+    if (getPopupMenu() == null || getMenuComponentCount() == 0)
+      return null;
+    
     return (Component) popupMenu.getComponentAtIndex(index);
   }
 
@@ -591,7 +609,7 @@
    */
   public Component[] getMenuComponents()
   {
-    return popupMenu.getComponents();
+    return getPopupMenu().getComponents();
   }
 
   /**
@@ -626,6 +644,11 @@
    */
   public JPopupMenu getPopupMenu()
   {
+    if (popupMenu == null)
+      {
+        popupMenu = new JPopupMenu();
+        popupMenu.setInvoker(this);
+      }
     return popupMenu;
   }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]