CheckBoxMenuItem
A menu item carrying a checkmark: a JCheckBoxMenuItem that shows checked and reports the user's toggle through onCheckedChange.
A toggle the caller does not answer with a matching checked is settled back onto the declared value, so the mark on screen is the one the composition holds.
Parameters
the text of the menu item
whether the item shows its checkmark
callback invoked with the checked state when the item is activated
the SwingModifier applied to the underlying component
the key combination that activates the item without navigating the menu hierarchy, displayed next to its text; null (the default) leaves the item without one
See also
A JCheckBoxMenuItem driven by a raw ActionListener instead of an onCheckedChange lambda. The listener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.
Parameters
the text of the menu item
whether the menu item is checked
the listener notified when the item is toggled
the SwingModifier applied to the underlying component
the key combination that activates the item without navigating the menu hierarchy, displayed next to its text; null (the default) leaves the item without one