Java Doc for CheckboxMenuItem.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.MenuComponent
      java.awt.MenuItem
         java.awt.CheckboxMenuItem

CheckboxMenuItem
public class CheckboxMenuItem extends MenuItem implements ItemSelectable,Accessible(Code)
This class represents a check box that can be included in a menu. Selecting the check box in the menu changes its state from "on" to "off" or from "off" to "on."

The following picture depicts a menu which contains an instance of CheckBoxMenuItem:

Menu labeled Examples, containing items Basic, Simple, Check, and More Examples. The Check item is a CheckBoxMenuItem instance, in the off state.

The item labeled Check shows a check box menu item in its "off" state.

When a check box menu item is selected, AWT sends an item event to the item. Since the event is an instance of ItemEvent, the processEvent method examines the event and passes it along to processItemEvent. The latter method redirects the event to any ItemListener objects that have registered an interest in item events generated by this menu item.
version:
   1.79, 05/05/07
author:
   Sami Shaio
See Also:   java.awt.event.ItemEvent
See Also:   java.awt.event.ItemListener
since:
   JDK1.0


Inner Class :protected class AccessibleAWTCheckboxMenuItem extends AccessibleAWTMenuItem implements AccessibleAction,AccessibleValue

Field Summary
transient  ItemListeneritemListener
    
 booleanstate
    

Constructor Summary
public  CheckboxMenuItem()
     Create a check box menu item with an empty label.
public  CheckboxMenuItem(String label)
     Create a check box menu item with the specified label.
public  CheckboxMenuItem(String label, boolean state)
     Create a check box menu item with the specified label and state.

Method Summary
public synchronized  voidaddItemListener(ItemListener l)
     Adds the specified item listener to receive item events from this check box menu item.
public  voidaddNotify()
     Creates the peer of the checkbox item.
 StringconstructComponentName()
     Construct a name for this MenuComponent.
 voiddoMenuEvent(long when, int modifiers)
    
 booleaneventEnabled(AWTEvent e)
    
public  AccessibleContextgetAccessibleContext()
     Gets the AccessibleContext associated with this CheckboxMenuItem.
public synchronized  ItemListener[]getItemListeners()
     Returns an array of all the item listeners registered on this checkbox menuitem.
public  T[]getListeners(Class<T> listenerType)
     Returns an array of all the objects currently registered as FooListeners upon this CheckboxMenuItem.
public synchronized  Object[]getSelectedObjects()
     Returns the an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
public  booleangetState()
    
public  StringparamString()
     Returns a string representing the state of this CheckBoxMenuItem.
protected  voidprocessEvent(AWTEvent e)
     Processes events on this check box menu item.
protected  voidprocessItemEvent(ItemEvent e)
     Processes item events occurring on this check box menu item by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this menu item.

public synchronized  voidremoveItemListener(ItemListener l)
     Removes the specified item listener so that it no longer receives item events from this check box menu item.
public synchronized  voidsetState(boolean b)
     Sets this check box menu item to the specifed state. The boolean value true indicates "on" while false indicates "off."

Note that this method should be primarily used to initialize the state of the check box menu item.


Field Detail
itemListener
transient ItemListener itemListener(Code)



state
boolean state(Code)
The state of a checkbox menu item
See Also:   CheckboxMenuItem.getState()
See Also:   CheckboxMenuItem.setState(boolean)




Constructor Detail
CheckboxMenuItem
public CheckboxMenuItem() throws HeadlessException(Code)
Create a check box menu item with an empty label. The item's state is initially set to "off."
exception:
  HeadlessException - if GraphicsEnvironment.isHeadless()returns true
See Also:   java.awt.GraphicsEnvironment.isHeadless
since:
   JDK1.1



CheckboxMenuItem
public CheckboxMenuItem(String label) throws HeadlessException(Code)
Create a check box menu item with the specified label. The item's state is initially set to "off."
Parameters:
  label - a string label for the check box menu item,or null for an unlabeled menu item.
exception:
  HeadlessException - if GraphicsEnvironment.isHeadless()returns true
See Also:   java.awt.GraphicsEnvironment.isHeadless



CheckboxMenuItem
public CheckboxMenuItem(String label, boolean state) throws HeadlessException(Code)
Create a check box menu item with the specified label and state.
Parameters:
  label - a string label for the check box menu item, or null for an unlabeled menu item.
Parameters:
  state - the initial state of the menu item, wheretrue indicates "on" andfalse indicates "off."
exception:
  HeadlessException - if GraphicsEnvironment.isHeadless()returns true
See Also:   java.awt.GraphicsEnvironment.isHeadless
since:
   JDK1.1




Method Detail
addItemListener
public synchronized void addItemListener(ItemListener l)(Code)
Adds the specified item listener to receive item events from this check box menu item. Item events are sent in response to user actions, but not in response to calls to setState(). If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  l - the item listener
See Also:   CheckboxMenuItem.removeItemListener
See Also:   CheckboxMenuItem.getItemListeners
See Also:   CheckboxMenuItem.setState
See Also:   java.awt.event.ItemEvent
See Also:   java.awt.event.ItemListener
since:
   JDK1.1




addNotify
public void addNotify()(Code)
Creates the peer of the checkbox item. This peer allows us to change the look of the checkbox item without changing its functionality. Most applications do not call this method directly.
See Also:   java.awt.Toolkit.createCheckboxMenuItem(java.awt.CheckboxMenuItem)
See Also:   java.awt.Component.getToolkit



constructComponentName
String constructComponentName()(Code)
Construct a name for this MenuComponent. Called by getName() when the name is null.



doMenuEvent
void doMenuEvent(long when, int modifiers)(Code)



eventEnabled
boolean eventEnabled(AWTEvent e)(Code)



getAccessibleContext
public AccessibleContext getAccessibleContext()(Code)
Gets the AccessibleContext associated with this CheckboxMenuItem. For checkbox menu items, the AccessibleContext takes the form of an AccessibleAWTCheckboxMenuItem. A new AccessibleAWTCheckboxMenuItem is created if necessary. an AccessibleAWTCheckboxMenuItem that serves as the AccessibleContext of this CheckboxMenuItem
since:
   1.3



getItemListeners
public synchronized ItemListener[] getItemListeners()(Code)
Returns an array of all the item listeners registered on this checkbox menuitem. all of this checkbox menuitem's ItemListenersor an empty array if no item listeners are currently registered
See Also:   CheckboxMenuItem.addItemListener
See Also:   CheckboxMenuItem.removeItemListener
See Also:   java.awt.event.ItemEvent
See Also:   java.awt.event.ItemListener
since:
   1.4



getListeners
public T[] getListeners(Class<T> listenerType)(Code)
Returns an array of all the objects currently registered as FooListeners upon this CheckboxMenuItem. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a CheckboxMenuItem c for its item listeners with the following code:

ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));
If no such listeners exist, this method returns an empty array.
Parameters:
  listenerType - the type of listeners requested; this parametershould specify an interface that descends fromjava.util.EventListener an array of all objects registered asFooListeners on this checkbox menuitem,or an empty array if no suchlisteners have been added
exception:
  ClassCastException - if listenerTypedoesn't specify a class or interface that implementsjava.util.EventListener
See Also:   CheckboxMenuItem.getItemListeners
since:
   1.3



getSelectedObjects
public synchronized Object[] getSelectedObjects()(Code)
Returns the an array (length 1) containing the checkbox menu item label or null if the checkbox is not selected.
See Also:   ItemSelectable



getState
public boolean getState()(Code)
Determines whether the state of this check box menu item is "on" or "off." the state of this check box menu item, wheretrue indicates "on" andfalse indicates "off"
See Also:   CheckboxMenuItem.setState



paramString
public String paramString()(Code)
Returns a string representing the state of this CheckBoxMenuItem. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null. the parameter string of this check box menu item



processEvent
protected void processEvent(AWTEvent e)(Code)
Processes events on this check box menu item. If the event is an instance of ItemEvent, this method invokes the processItemEvent method. If the event is not an item event, it invokes processEvent on the superclass.

Check box menu items currently support only item events.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.
Parameters:
  e - the event
See Also:   java.awt.event.ItemEvent
See Also:   CheckboxMenuItem.processItemEvent
since:
   JDK1.1




processItemEvent
protected void processItemEvent(ItemEvent e)(Code)
Processes item events occurring on this check box menu item by dispatching them to any registered ItemListener objects.

This method is not called unless item events are enabled for this menu item. Item events are enabled when one of the following occurs:

  • An ItemListener object is registered via addItemListener.
  • Item events are enabled via enableEvents.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.
Parameters:
  e - the item event
See Also:   java.awt.event.ItemEvent
See Also:   java.awt.event.ItemListener
See Also:   CheckboxMenuItem.addItemListener
See Also:   java.awt.MenuItem.enableEvents
since:
   JDK1.1




removeItemListener
public synchronized void removeItemListener(ItemListener l)(Code)
Removes the specified item listener so that it no longer receives item events from this check box menu item. If l is null, no exception is thrown and no action is performed.

Refer to AWT Threading Issues for details on AWT's threading model.
Parameters:
  l - the item listener
See Also:   CheckboxMenuItem.addItemListener
See Also:   CheckboxMenuItem.getItemListeners
See Also:   java.awt.event.ItemEvent
See Also:   java.awt.event.ItemListener
since:
   JDK1.1




setState
public synchronized void setState(boolean b)(Code)
Sets this check box menu item to the specifed state. The boolean value true indicates "on" while false indicates "off."

Note that this method should be primarily used to initialize the state of the check box menu item. Programmatically setting the state of the check box menu item will not trigger an ItemEvent. The only way to trigger an ItemEvent is by user interaction.
Parameters:
  b - true if the check boxmenu item is on, otherwise false
See Also:   CheckboxMenuItem.getState




Fields inherited from java.awt.MenuItem
String actionCommand(Code)(Java Doc)
transient ActionListener actionListener(Code)(Java Doc)
boolean enabled(Code)(Java Doc)
long eventMask(Code)(Java Doc)
String label(Code)(Java Doc)

Methods inherited from java.awt.MenuItem
public synchronized void addActionListener(ActionListener l)(Code)(Java Doc)
public void addNotify()(Code)(Java Doc)
String constructComponentName()(Code)(Java Doc)
public void deleteShortcut()(Code)(Java Doc)
void deleteShortcut(MenuShortcut s)(Code)(Java Doc)
public synchronized void disable()(Code)(Java Doc)
final protected void disableEvents(long eventsToDisable)(Code)(Java Doc)
void doMenuEvent(long when, int modifiers)(Code)(Java Doc)
public synchronized void enable()(Code)(Java Doc)
public void enable(boolean b)(Code)(Java Doc)
final protected void enableEvents(long eventsToEnable)(Code)(Java Doc)
boolean eventEnabled(AWTEvent e)(Code)(Java Doc)
public AccessibleContext getAccessibleContext()(Code)(Java Doc)
public String getActionCommand()(Code)(Java Doc)
final String getActionCommandImpl()(Code)(Java Doc)
public synchronized ActionListener[] getActionListeners()(Code)(Java Doc)
public String getLabel()(Code)(Java Doc)
public T[] getListeners(Class<T> listenerType)(Code)(Java Doc)
public MenuShortcut getShortcut()(Code)(Java Doc)
MenuItem getShortcutMenuItem(MenuShortcut s)(Code)(Java Doc)
boolean handleShortcut(KeyEvent e)(Code)(Java Doc)
public boolean isEnabled()(Code)(Java Doc)
public String paramString()(Code)(Java Doc)
protected void processActionEvent(ActionEvent e)(Code)(Java Doc)
protected void processEvent(AWTEvent e)(Code)(Java Doc)
public synchronized void removeActionListener(ActionListener l)(Code)(Java Doc)
public void setActionCommand(String command)(Code)(Java Doc)
public synchronized void setEnabled(boolean b)(Code)(Java Doc)
public synchronized void setLabel(String label)(Code)(Java Doc)
public void setShortcut(MenuShortcut s)(Code)(Java Doc)

Fields inherited from java.awt.MenuComponent
AccessibleContext accessibleContext(Code)(Java Doc)
final static String actionListenerK(Code)(Java Doc)
transient AppContext appContext(Code)(Java Doc)
Font font(Code)(Java Doc)
final static String itemListenerK(Code)(Java Doc)
boolean newEventsOnly(Code)(Java Doc)
transient MenuContainer parent(Code)(Java Doc)
transient MenuComponentPeer peer(Code)(Java Doc)

Methods inherited from java.awt.MenuComponent
String constructComponentName()(Code)(Java Doc)
final public void dispatchEvent(AWTEvent e)(Code)(Java Doc)
void dispatchEventImpl(AWTEvent e)(Code)(Java Doc)
boolean eventEnabled(AWTEvent e)(Code)(Java Doc)
int getAccessibleChildIndex(MenuComponent child)(Code)(Java Doc)
public AccessibleContext getAccessibleContext()(Code)(Java Doc)
int getAccessibleIndexInParent()(Code)(Java Doc)
AccessibleStateSet getAccessibleStateSet()(Code)(Java Doc)
public Font getFont()(Code)(Java Doc)
final Font getFont_NoClientCode()(Code)(Java Doc)
public String getName()(Code)(Java Doc)
public MenuContainer getParent()(Code)(Java Doc)
final MenuContainer getParent_NoClientCode()(Code)(Java Doc)
public MenuComponentPeer getPeer()(Code)(Java Doc)
final protected Object getTreeLock()(Code)(Java Doc)
protected String paramString()(Code)(Java Doc)
public boolean postEvent(Event evt)(Code)(Java Doc)
protected void processEvent(AWTEvent e)(Code)(Java Doc)
public void removeNotify()(Code)(Java Doc)
public void setFont(Font f)(Code)(Java Doc)
public void setName(String name)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.