Example usage for javax.swing JCheckBox setDisabledIcon

List of usage examples for javax.swing JCheckBox setDisabledIcon

Introduction

In this page you can find the example usage for javax.swing JCheckBox setDisabledIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The disabled icon for the button.")
public void setDisabledIcon(Icon disabledIcon) 

Source Link

Document

Sets the disabled icon for the button.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JCheckBox checkbox = new JCheckBox();

    // Set the unselected state icon
    Icon unselDisIcon = new ImageIcon("nosel-dis-icon.gif");
    checkbox.setDisabledIcon(unselDisIcon);

    // Set the selected state icon
    Icon selDisIcon = new ImageIcon("sel-dis-icon.gif");
    checkbox.setDisabledSelectedIcon(selDisIcon);

}

From source file:JCheckBoxCustomIcon.java

public JCheckBoxCustomIcon() {
    setSize(300, 300);/*from w  w  w .  ja  va  2s.  c o m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    JCheckBox checkBox = new JCheckBox("Check me!");
    checkBox.setSelected(true);

    // Set default icon for checkbox
    checkBox.setIcon(new ImageIcon("icon.png"));
    // Set selected icon when checkbox state is selected
    checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png"));
    // Set disabled icon for checkbox
    checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png"));
    // Set disabled-selected icon for checkbox
    checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png"));
    // Set checkbox icon when checkbox is pressed
    checkBox.setPressedIcon(new ImageIcon("pressedIcon.png"));
    // Set icon when a mouse is over the checkbox
    checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png"));
    // Set icon when a mouse is over a selected checkbox
    checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png"));

    getContentPane().add(checkBox);
}

From source file:Main.java

public Main() {
    setSize(300, 300);//from  w w  w  .j  a  v  a  2  s.  co m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    JCheckBox checkBox = new JCheckBox("Check me!");
    checkBox.setSelected(true);

    // Set default icon for checkbox
    checkBox.setIcon(new ImageIcon("icon.png"));
    // Set selected icon when checkbox state is selected
    checkBox.setSelectedIcon(new ImageIcon("selectedIcon.png"));
    // Set disabled icon for checkbox
    checkBox.setDisabledIcon(new ImageIcon("disabledIcon.png"));
    // Set disabled-selected icon for checkbox
    checkBox.setDisabledSelectedIcon(new ImageIcon("disabledSelectedIcon.png"));
    // Set checkbox icon when checkbox is pressed
    checkBox.setPressedIcon(new ImageIcon("pressedIcon.png"));
    // Set icon when a mouse is over the checkbox
    checkBox.setRolloverIcon(new ImageIcon("rolloverIcon.png"));
    // Set icon when a mouse is over a selected checkbox
    checkBox.setRolloverSelectedIcon(new ImageIcon("rolloverSelectedIcon.png"));

    getContentPane().add(checkBox);
}