List of usage examples for javax.swing JCheckBox setPressedIcon
@BeanProperty(visualUpdate = true, description = "The pressed icon for the button.") public void setPressedIcon(Icon pressedIcon)
From source file:Main.java
public static void main(String[] argv) throws Exception { JCheckBox checkbox = new JCheckBox(); Icon pressedIcon = new ImageIcon("pres-icon.gif"); checkbox.setPressedIcon(pressedIcon); }
From source file:JCheckBoxCustomIcon.java
public JCheckBoxCustomIcon() { setSize(300, 300);// w ww . j a va 2 s . com 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 ww w . j a va 2s. c om 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); }