static JCheckBox jCheckBox() {
  ret swingNu(JCheckBox);
}

static JCheckBox jCheckBox(bool checked) {
  ret swingNu(JCheckBox, "", checked);
}

static JCheckBox jCheckBox(S text, bool checked) {
  ret swingNu(JCheckBox, text, checked);
}

static JCheckBox jCheckBox(S text) {
  ret swingNu(JCheckBox, text);
}
  
static JCheckBox jCheckBox(S text, bool checked, O onChange) {
  JCheckBox cb = jCheckBox(text, checked);
  cb.setText(text);
  ret cb;
}
  
// onChange can be a Runnable or a voidfunc(bool)
static JCheckBox jCheckBox(bool checked, fO onChange) {
  final JCheckBox cb = jCheckBox(checked);
  cb.addChangeListener(new ChangeListener {
    public void stateChanged(ChangeEvent e) {
      pcallF(onChange, cb.isSelected());
    }
  });
  ret cb;
}

static JCheckBox jCheckBox(bool checked, S text, IVF1<Bool> onChangeAndNow) {
  var cb = jCheckBox(text, checked);
  onChangeAndNow(cb, r { onChangeAndNow.get(isChecked(cb)); });
  ret cb;
}