final JCheckBox box = new JCheckBox("State");
box.setEnabled(false);
JButton button = new JButton(new AbstractAction("Enable/Disable") {
private static final long serialVersionUID = 7961054013653375370L;
public void actionPerformed(ActionEvent e) {
box.setSelected(!box.isSelected());
}
});
/**
* ES HANDELT SICH HIERBEI UM EINEN HACK!!!!!!!
*/
public static class DoNothingJCheckBox extends JCheckBox {
private static final long serialVersionUID = -5259327954127164344L;
public DoNothingJCheckBox(String text) {
super(text);
}
@Override
protected ChangeListener createChangeListener() {
return new ChangeListener() {
public void stateChanged(ChangeEvent e) {
// do nothing
}
};
}
}
@Override
public void setSelected(boolean b) {
super.setSelected(b);
// AbstractButton#updateMnemonicProperties() ist private !!?
fireStateChanged();
repaint();
}
public class GlassPane extends JPanel{
public GlassPane(){
setOpaque( false );
}
Mewel hat gesagt.:...ohne sehr viel an meinem Code umzuschreiben nicht nutzen...
final JCheckBox box = new JCheckBox("State");
box.setModel(new DefaultButtonModel() {
private static final long serialVersionUID = 5259327923427164344L;
@Override
public void setSelected(boolean b) {
if (!isArmed()) {
super.setSelected(b);
}
}
});