/[classpath]/classpath/java/awt/Menu.java
ViewVC logotype

Diff of /classpath/java/awt/Menu.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Sun Jan 13 15:45:15 2002 UTC revision 1.6 by tromey, Tue Jan 22 22:00:14 2002 UTC
# Line 1  Line 1 
1  /* Menu.java -- A Java AWT Menu  /* Menu.java -- A Java AWT Menu
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 70  private boolean isTearOff; Line 70  private boolean isTearOff;
70    */    */
71  private boolean isHelpMenu;  private boolean isHelpMenu;
72    
73    // From the serialization spec.  FIXME: what should it be?
74    private int menuSerializedDataVersion;
75    
76    static final MenuItem separator = new MenuItem("-");
77    
78  /*************************************************************************/  /*************************************************************************/
79    
80  /*  /*
# Line 194  getItem(int index) Line 199  getItem(int index)
199  public MenuItem  public MenuItem
200  add(MenuItem item)  add(MenuItem item)
201  {  {
   // FIXME: How do I remove from previous menu's?  
   
202    items.addElement(item);    items.addElement(item);
203      if (item.parent != null)
204        {
205          item.parent.remove(item);
206        }
207      item.parent = this;
208    
209      if (peer != null)
210        {
211          MenuPeer mp = (MenuPeer) peer;
212          mp.addItem(item);
213        }
214    
215    MenuPeer mp = (MenuPeer)getPeer();    return item;
   if (mp != null)  
     mp.addItem(item);  
   
   return(item);  
216  }  }
217    
218  /*************************************************************************/  /*************************************************************************/
# Line 240  insert(MenuItem item, int index) Line 250  insert(MenuItem item, int index)
250    items.insertElementAt(item, index);    items.insertElementAt(item, index);
251    
252    MenuPeer mp = (MenuPeer)getPeer();    MenuPeer mp = (MenuPeer)getPeer();
253      // FIXME: Need to add a peer method here.
254  //    if (mp != null)  //    if (mp != null)
255  //      mp.insertItem(item, index);  //      mp.insertItem(item, index);
256  }  }
# Line 269  insert(String label, int index) Line 280  insert(String label, int index)
280  public void  public void
281  addSeparator()  addSeparator()
282  {  {
283    // FIXME: How do we note in the items array what this is?    add(separator);
   MenuPeer mp = (MenuPeer)getPeer();  
   if (mp != null)  
     mp.addSeparator();  
284  }  }
285    
286  /*************************************************************************/  /*************************************************************************/
# Line 290  addSeparator() Line 298  addSeparator()
298  public void  public void
299  insertSeparator(int index)  insertSeparator(int index)
300  {  {
301    if (index < 0)    insert(separator, index);
     throw new IllegalArgumentException("Index is less than zero");  
   
   // FIXME: How do we note in the items array what this is?  
 //    MenuPeer mp = (MenuPeer)getPeer();  
 //    if (mp != null)  
 //      mp.insertSeparator(index);  
302  }  }
303    
304  /*************************************************************************/  /*************************************************************************/
# Line 345  public synchronized void Line 347  public synchronized void
347  removeAll()  removeAll()
348  {  {
349    int count = getItemCount();    int count = getItemCount();
350    if (count > 0)    for(int i = 0; i < count; i++)
351      for(int i = 0; i < count; i++)      {
352         remove(i);        // We must always remove item 0.
353          remove(0);
354        }
355  }  }
356    
357  /*************************************************************************/  /*************************************************************************/
# Line 358  removeAll() Line 362  removeAll()
362  public void  public void
363  addNotify()  addNotify()
364  {  {
365    if (getPeer() != null)    if (peer != null)
366      return;      peer = getToolkit().createMenu(this);
367      super.addNotify ();
   setPeer((MenuComponentPeer)getToolkit().createMenu(this));  
368  }  }
369    
370  /*************************************************************************/  /*************************************************************************/
# Line 385  removeNotify() Line 388  removeNotify()
388  public String  public String
389  paramString()  paramString()
390  {  {
391    return(getClass().getName() + "(label=" + getLabel() + ")");    return (",isTearOff=" + isTearOff + ",isHelpMenu=" + isHelpMenu
392              + super.paramString());
393  }  }
394    
395  } // class Menu  // Accessibility API not yet implemented.
396    // public AccessibleContext getAccessibleContext()
397    
398    } // class Menu

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26