java-gnome version 4.0.19

org.gnome.gtk
Class CheckMenuItem

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.Object
                  extended by org.gnome.gtk.Widget
                      extended by org.gnome.gtk.Container
                          extended by org.gnome.gtk.Bin
                              extended by org.gnome.gtk.Item
                                  extended by org.gnome.gtk.MenuItem
                                      extended by org.gnome.gtk.CheckMenuItem
All Implemented Interfaces:
Activatable
Direct Known Subclasses:
RadioMenuItem

public class CheckMenuItem
extends MenuItem

A MenuItem that maintains a binary state.

A CheckMenuItem is just like a MenuItem, but additionally it displays a "check box" alongside the normal Label, indicating the state of the boolean value it holds. When that value is set to true, the item is active and the box shows the check mark.

You can use a CheckMenuItem as a way to allow users of your application enable or disable a feature in an application. This is often used within to toggle options, for example to let the user hide an optional Widget of your user interface.

The active state is switched automatically when the user activates the MenuItem. You can access the current state with the getActive() method. And while you can still connect to the MenuItem.Active signal, CheckMenuItem provides the CheckMenuItem.Toggled signal, emitted when the active state changes.

See the parent class for further details general to all MenuItems.

Since:
4.0.4
Author:
Vreixo Formoso

Nested Class Summary
static interface CheckMenuItem.Toggled
          The handler interface for a change in the active state.
 
Nested classes/interfaces inherited from class org.gnome.gtk.MenuItem
MenuItem.Activate
 
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
 
Nested classes/interfaces inherited from class org.gnome.gtk.Object
Object.Destroy
 
Constructor Summary
CheckMenuItem()
          Construct a CheckMenuItem
CheckMenuItem(String mnemonicLabel)
          Construct a CheckMenuItem with a given text Label.
CheckMenuItem(String mnemonicLabel, CheckMenuItem.Toggled handler)
          Construct a CheckMenuItem with a given text label, and additionally connect a handler to its CheckMenuItem.Toggled signal.
 
Method Summary
 void connect(CheckMenuItem.Toggled handler)
          Connect a CheckMenuItem.Toggled handler to the Widget.
 boolean getActive()
          Retrieve the active state of the item.
 boolean getInconsistent()
          Get the inconsistent state.
 void setActive(boolean isActive)
          Set the active state of the Item.
 void setInconsistent(boolean setting)
          Set the inconsistent state.
 
Methods inherited from class org.gnome.gtk.MenuItem
connect, getRelatedAction, getSubmenu, setAccelerator, setRelatedAction, setSubmenu
 
Methods inherited from class org.gnome.gtk.Bin
getChild
 
Methods inherited from class org.gnome.gtk.Container
add, getChildren, remove, setBorderWidth
 
Methods inherited from class org.gnome.gtk.Widget
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getSensitive, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, realize, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.gnome.gtk.Object
connect, destroy
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CheckMenuItem

public CheckMenuItem()
Construct a CheckMenuItem

Since:
4.0.4

CheckMenuItem

public CheckMenuItem(String mnemonicLabel)
Construct a CheckMenuItem with a given text Label. The text may contain underscores (_) which, if present, will indicate the mnemonic which will activate that CheckMenuItem directly if that key is pressed while viewing the Menu.

Since:
4.0.4

CheckMenuItem

public CheckMenuItem(String mnemonicLabel,
                     CheckMenuItem.Toggled handler)
Construct a CheckMenuItem with a given text label, and additionally connect a handler to its CheckMenuItem.Toggled signal. This affords you the convenience of being able to add a MenuItem fairly compactly:
 editMenu.append(new MenuItem("_Paste", new CheckMenuItem.Toggled() {
     public void onToggled(MenuItem source) {
         ...
     }
 }));
 

Since:
4.0.4
Method Detail

connect

public void connect(CheckMenuItem.Toggled handler)
Connect a CheckMenuItem.Toggled handler to the Widget.

Since:
4.0.4

getActive

public boolean getActive()
Retrieve the active state of the item.

Since:
4.0.4

getInconsistent

public boolean getInconsistent()
Get the inconsistent state.

Since:
4.0.4
See Also:
setInconsistent(boolean)

setActive

public void setActive(boolean isActive)
Set the active state of the Item. This is switched automatically when the user activates (clicks) the menu item, but in some situations you will want to change it manually.

Since:
4.0.4

setInconsistent

public void setInconsistent(boolean setting)
Set the inconsistent state. This refers to an additional third state meaning that currently it cannot be decided what is the active state of the item.

Think, for example, in a text editor application, in which a CheckMenuItem is used to choose between a bold or a normal font. If the user selects a range of text where both normal and bold fonts are being used, the state is inconsistent, and we want to mark it in a different way.

However, note that, while such property can be really useful in a ToggleButton, its utility in a CheckMenuItem is really unclear.

Notice also that this property only affects visual appearance, it doesn't affect the semantics of the Widget.

Since:
4.0.4


java-gnome