Element: CheckBoxMenuItem.

Icon: 

Text: A check box for menus.

Description: A CheckBoxMenuItem  is the particular implementation of CheckBox for menus. Thus, it is used to display and modify a boolean value. It can display a text, an image, or both. Check boxes can invoke an action when the value is changed. Moreover, individual actions can also be specified for the cases in which the value is selected to be true or false. If both are set, this second action is always invoked after the first one.

Check boxes can be disabled using the "Enabled" property. In this case, the interface is greyed out.

Table of properties

Name Description Values accepted
Variable
Variable The variable to edit using this element. A boolean variable.
Selected Initial state of the variable.  A boolean variable or one of the constants true or false.

Decoration

Text The text displayed by the element. Any constant or variable of type String.
Image The image displayed by the element. Any constant or variable of type String, corresponding to a GIF or animated GIF image. The string indicates the path to the corresponding image file. The path can be relative to the working directory or an Internet URL.
Sel. Image The image displayed by the element when the value is true. Any constant or variable of type String, corresponding to a GIF or animated GIF image. The string indicates the path to the corresponding image file. The path can be relative to the working directory or an Internet URL.
Accelerator The key character that activates this menu (from anywhere in the program).  A string that specifies the accelerator as a parameter to new javax.swing.KeyStroke(String)

Here are some examples:

  • "INSERT"
  • control DELETE"

  • "alt shift X"

  • "alt shift released X" 

  • "typed a" 

Mnemonic The key that (together with Alt) activates this menu. A string with a single character.
Alignment How to align the text of the element. One of the constants: left, center or right

It can also be an integer variable (consult the Javadoc reference for the class javax.swing.JButton). 

Interaction

Enabled Whether the element responds to user interaction. A boolean variable or one of the constants true or false.
Action The action to invoke when the value changes. The Java code to invoke for the action. 
Action On The action to invoke when the value changes to true. The Java code to invoke for the action. 
Action Off The action to invoke when the value changes to false. The Java code to invoke for the action. 
Graphical Aspect
Size The size of the element. An Object variable of the class java.awt.Dimension or the integer values for the width and the height, respectively, separated by a comma.
Background The color used for the background of the element. An Object variable of the class java.awt.Color or one of the predefined colors: black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, yellow.

A color can also be specified providing its integer RGB coordinates (between 0 and 255), plus an optional transparency coordinate.

The default value is decided by the system.

Foreground The color used for the text displayed by the element. See the values for the Background property.
Font The font used for the text displayed by the element. An Object variable of the class java.awt.Font or a set of family, style and size, separated by commas. The style must be one of  plain, bold, italic, bold | italic. Example: Monospaced,italic,18.

The default value is decided by the system.

Tooltip The text displayed when the cursor lingers on top of the element. Any constant or variable of type String.