Represents a built in, or custom, state in Nimbus.
Synth provides several built in states, which are:
However, there are many more states that could be described in a LookAndFeel, and it would be nice to style components differently based on these different states. For example, a progress bar could be "indeterminate". It would be very convenient to allow this to be defined as a "state".
This class, State, is intended to be used for such situations. Simply implement the abstract #isInState method. It returns true if the given JComponent is "in this state", false otherwise. This method will be called many times in performance sensitive loops. It must execute very quickly.
For example, the following might be an implementation of a custom "Indeterminate" state for JProgressBars:
public final class IndeterminateState extends State<JProgressBar> {
public IndeterminateState() {
super("Indeterminate");
}
@Override
protected boolean isInState(JProgressBar c) {
return c.isIndeterminate();
}
}
Modifier and Type | Class and Description |
---|---|
pack-priv static class |
Modifier and Type | Field and Description |
---|---|
pack-priv static final State | |
pack-priv static final State | |
pack-priv static final State | |
pack-priv static final State | |
pack-priv static final State | |
private String | |
pack-priv static final State | |
pack-priv static final State | |
pack-priv static final Map |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
pack-priv String | |
pack-priv static State. | |
pack-priv boolean | |
protected abstract boolean | Returns: true ifc is in the custom state represented by
this State instancethe JComponent to test. This will never be null. c)Gets whether the specified JComponent is in the custom state represented by this class. |
pack-priv static boolean | |
public String |
Default | back to summary |
---|---|
pack-priv static final State<JComponent> Default |
Disabled | back to summary |
---|---|
pack-priv static final State<JComponent> Disabled |
Enabled | back to summary |
---|---|
pack-priv static final State<JComponent> Enabled |
Focused | back to summary |
---|---|
pack-priv static final State<JComponent> Focused |
MouseOver | back to summary |
---|---|
pack-priv static final State<JComponent> MouseOver |
name | back to summary |
---|---|
private String name |
Pressed | back to summary |
---|---|
pack-priv static final State<JComponent> Pressed |
Selected | back to summary |
---|---|
pack-priv static final State<JComponent> Selected |
standardStates | back to summary |
---|---|
pack-priv static final Map<String, State. |
State | back to summary |
---|---|
protected State(String name) Create a new custom State. Specify the name for the state. The name should be unique within the states set for any one particular component. The name of the state should coincide with the name used in UIDefaults. For example, the following would be correct:
|
getName | back to summary |
---|---|
pack-priv String getName() |
getStandardState | back to summary |
---|---|
pack-priv static State. |
isInState | back to summary |
---|---|
pack-priv boolean isInState(T c, int s) This is the main entry point, called by NimbusStyle. There are both custom states and standard states. Standard states correlate to the states defined in SynthConstants. When a UI delegate constructs a SynthContext, it specifies the state that the component is in according to the states defined in SynthConstants. Our NimbusStyle will then take this state, and query each State instance in the style asking whether isInState(c, s). Now, only the standard states care about the "s" param. So we have this odd arrangement:
|
isInState | back to summary |
---|---|
protected abstract boolean isInState(T c) Gets whether the specified JComponent is in the custom state represented by this class. This is an extremely performance sensitive loop. Please take proper precautions to ensure that it executes quickly. Nimbus uses this method to help determine what state a JComponent is
in. For example, a custom State could exist for JProgressBar such that
it would return
|
isStandardStateName | back to summary |
---|---|
pack-priv static boolean isStandardStateName(String name) |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object. |
Modifier and Type | Field and Description |
---|---|
private int |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public int | |
pack-priv boolean | isInState(JComponent c, int s)
Overrides javax. This is the main entry point, called by NimbusStyle. |
protected boolean | isInState(JComponent
the JComponent to test. This will never be null. c)Implements abstract javax. Gets whether the specified JComponent is in the custom state represented by this class. |
private static String |
state | back to summary |
---|---|
private int state |
StandardState | back to summary |
---|---|
private StandardState(int state) |
getState | back to summary |
---|---|
public int getState() |
isInState | back to summary |
---|---|
pack-priv boolean isInState(JComponent c, int s) Overrides javax. Doc from javax. This is the main entry point, called by NimbusStyle. There are both custom states and standard states. Standard states correlate to the states defined in SynthConstants. When a UI delegate constructs a SynthContext, it specifies the state that the component is in according to the states defined in SynthConstants. Our NimbusStyle will then take this state, and query each State instance in the style asking whether isInState(c, s). Now, only the standard states care about the "s" param. So we have this odd arrangement:
|
isInState | back to summary |
---|---|
protected boolean isInState(JComponent c) Implements abstract javax. Doc from javax. Gets whether the specified JComponent is in the custom state represented by this class. This is an extremely performance sensitive loop. Please take proper precautions to ensure that it executes quickly. Nimbus uses this method to help determine what state a JComponent is
in. For example, a custom State could exist for JProgressBar such that
it would return
|
toString | back to summary |
---|---|
private static String toString(int state) |