Skip to content

Instantly share code, notes, and snippets.

@koichiro
Created April 14, 2009 06:06
Show Gist options
  • Save koichiro/95002 to your computer and use it in GitHub Desktop.
Save koichiro/95002 to your computer and use it in GitHub Desktop.
class Main {
static class JCheckboxWithLabel extends JCheckbox {
public JLabel label;
public JCheckboxWithLabel(String label) {
super();
label = new JLabel(label);
}
}
static public void main(String[] args) {
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent e) {
JCheckboxWithLabel checkbox = (JCheckboxWithLabel) e.getSource();
checkbox.label.setBackground(/* てきとーに色 */);
}
}
JCheckboxWithLabel checkbox1 = new JCheckboxWithLabel("checkbox1");
JCheckboxWithLabel checkbox2 = new JCheckboxWithLabel("checkbox2");
JCheckboxWithLabel checkbox3 = new JCheckboxWithLabel("checkbox3");
checkbox1.addActionListener(l);
checkbox2.addActionListener(l);
checkbox3.addActionListener(l);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment