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

Diff of /classpath/java/awt/MenuItem.java

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

revision 1.4 by mark, Sun Jan 13 15:45:15 2002 UTC revision 1.5 by tromey, Fri Jan 18 00:49:49 2002 UTC
# Line 1  Line 1 
1  /* MenuItem.java -- An item in a menu  /* MenuItem.java -- An item in a menu
2     Copyright (C) 1999 Free Software Foundation, Inc.     Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 31  import java.awt.peer.MenuItemPeer; Line 31  import java.awt.peer.MenuItemPeer;
31  import java.awt.peer.MenuComponentPeer;  import java.awt.peer.MenuComponentPeer;
32  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
33  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
34    import java.util.EventListener;
35    
36  /**  /**
37    * This class represents an item in a menu.    * This class represents an item in a menu.
# Line 156  public synchronized void Line 157  public synchronized void
157  setLabel(String label)  setLabel(String label)
158  {  {
159    this.label = label;    this.label = label;
160      if (peer != null)
161    MenuItemPeer mip = (MenuItemPeer)getPeer();      {
162    if (mip != null)        MenuItemPeer mp = (MenuItemPeer) peer;
163      mip.setLabel(label);        mp.setLabel (label);
164        }
165  }  }
166    
167  /*************************************************************************/  /*************************************************************************/
# Line 191  setEnabled(boolean enabled) Line 193  setEnabled(boolean enabled)
193      return;      return;
194    
195    this.enabled = enabled;    this.enabled = enabled;
196      if (peer != null)
197    MenuItemPeer mip = (MenuItemPeer)getPeer();      {
198    if (mip != null)        MenuItemPeer mp = (MenuItemPeer) peer;
199      mip.setEnabled(enabled);        mp.setEnabled (enabled);
200        }
201  }  }
202    
203  /*************************************************************************/  /*************************************************************************/
# Line 320  protected final void Line 323  protected final void
323  enableEvents(long events)  enableEvents(long events)
324  {  {
325    eventMask |= events;    eventMask |= events;
326      // TODO: see comment in Component.enableEvents().    
327  }  }
328    
329  /*************************************************************************/  /*************************************************************************/
# Line 344  disableEvents(long events) Line 348  disableEvents(long events)
348  public void  public void
349  addNotify()  addNotify()
350  {  {
351    if (getPeer() != null)    if (peer != null)
352      return;      peer = getToolkit ().createMenuItem (this);
   
   setPeer((MenuComponentPeer)getToolkit().createMenuItem(this));  
353  }  }
354    
355  /*************************************************************************/  /*************************************************************************/
# Line 366  addActionListener(ActionListener listene Line 368  addActionListener(ActionListener listene
368    enableEvents(AWTEvent.ACTION_EVENT_MASK);    enableEvents(AWTEvent.ACTION_EVENT_MASK);
369  }  }
370    
371    public synchronized void
372    removeActionListener(ActionListener l)
373    {
374      action_listeners = AWTEventMulticaster.remove(action_listeners, l);
375    }
376    
377    /** Returns all registered EventListers of the given listenerType.
378     * listenerType must be a subclass of EventListener, or a
379     * ClassClassException is thrown.
380     * @since 1.3
381     */
382    public EventListener[]
383    getListeners(Class listenerType)
384    {
385      if (listenerType == ActionListener.class)
386        return Component.getListenersImpl(listenerType, action_listeners);
387      else
388        return Component.getListenersImpl(listenerType, null);
389    }
390    
391  /*************************************************************************/  /*************************************************************************/
392    
393    void
394    dispatchEventImpl(AWTEvent e)
395    {
396      if (e.id <= ActionEvent.ACTION_LAST
397          && e.id >= ActionEvent.ACTION_FIRST
398          && (action_listeners != null
399              || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
400        processEvent(e);
401    }
402    
403  /**  /**
404    * Processes the specified event by calling <code>processActionEvent()</code>    * Processes the specified event by calling <code>processActionEvent()</code>
405    * if it is an instance of <code>ActionEvent</code>.    * if it is an instance of <code>ActionEvent</code>.
# Line 409  paramString() Line 441  paramString()
441           ",actionCommand=" + actionCommand + ")");           ",actionCommand=" + actionCommand + ")");
442  }  }
443    
444  } // class MenuItem  // Accessibility API not yet implemented.
445    // public AccessibleContext getAccessibleContext()
446    
447    } // class MenuItem

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

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