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