Example usage for javax.swing JCheckBoxMenuItem setIcon

List of usage examples for javax.swing JCheckBoxMenuItem setIcon

Introduction

In this page you can find the example usage for javax.swing JCheckBoxMenuItem setIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The button's default icon")
public void setIcon(Icon defaultIcon) 

Source Link

Document

Sets the button's default icon.

Usage

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JCheckBoxMenuItem getIntelCheckBoxMenuItem(String text) {
    final JCheckBoxMenuItem box = new JCheckBoxMenuItem(text, UIImages.EMPTY_BOX_ICON.getImageIcon());
    // should do it through L&F, but couldn't find the way to do it
    // so we are using action listener to dynamically change icon
    box.addActionListener(new ActionListener() {
        @Override/*from  www.ja v  a2s  .com*/
        public void actionPerformed(ActionEvent e) {
            box.setIcon(box.isSelected() ? UIImages.CHECK_BOX_ICON.getImageIcon()
                    : UIImages.EMPTY_BOX_ICON.getImageIcon());
        }
    });
    return box;
}