static AutoCloseable tempDisableButton(final JButton b) { if (b == null) null; bool wasEnabled = swing(func -> bool { bool wasEnabled = isEnabled(b); if (wasEnabled) disableButton(b); ret wasEnabled; }); if (!wasEnabled) null; ret autocloseable { enableButton(b); }; }