public final class EverythingDisablerAndReenabler extends Object
JYT: Changed it so that it can remember what was the enabled state and restore this state.
Constructor and Description |
---|
EverythingDisablerAndReenabler(Container rootContainerForWhatShouldBeDisabled,
Class<?>[] componentClassesToBeIgnored) |
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables everything recursively, except the excluded types.
|
void |
reenable() |
void |
setEnabled(boolean enable)
Convenience method that calls
reenable() or disable()
depending on the specified boolean flag. |
public EverythingDisablerAndReenabler(Container rootContainerForWhatShouldBeDisabled, Class<?>[] componentClassesToBeIgnored)
rootContainerForWhatShouldBeDisabled
- NOT NULL! The Container whose components are to be recursively
disabled. The container itself will not be disabled.componentClassesToBeIgnored
- null or an array of classes (e.g. containing JLabel.class)
that should be excluded from disabling. Adding a Container
here does not affect the recursive process.IllegalArgumentException
- if the container argument is null. In case someone wonders
why I don't use NullPointerException
here: Null can
be a perfectly legal argument in other places, but here, it
is not. If an argument does not check out, the choice of
Exception, of course, is IllegalArgument, not NullPointer.public void setEnabled(boolean enable)
reenable()
or disable()
depending on the specified boolean flag.enable
- whether to re-enable (true
) or disable
(false
) the root container and descendants.public void disable()
IllegalStateException
- if called twice in a row.public void reenable()
IllegalStateException
- if called twice in a row or if disable() had not been called
yet.Copyright © 2015–2021 Fiji. All rights reserved.