|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.swing.Grouping
public class Grouping
Easily manipulate a "grouping" of JComponent objects.
You will often find yourself in a situation where you GUI interface has a bunch of items that need you would like to treat as a "group" at times.
This class allows you to group components
into a single container and then perform common operations on the
entire group.
The setEnabled(boolean) method can be particularily handy when
you will need to disable an entire set of options when your
application enters a certain state, and then re-enable them when
your application leaves the state.
This really requires an entire chapter (book) to fully understand the benefit of working with "group", but trust me in that its very handy (especially when GUI components are dynamically created from resource files).
Groupings| Constructor Summary | |
|---|---|
Grouping(String name)
Create a new "grouping" of components. |
|
| Method Summary | |
|---|---|
void |
addJComponent(JComponent c)
Add a new component to the group of components. |
String |
getName()
Get the "name" of the grouping. |
void |
removeJComponent(JComponent c)
Remove a component from the group of components. |
void |
setBackground(Color color)
Set the background color of the components. |
void |
setEnabled(boolean enable)
Enable/Disable ALL components in the grouping. |
void |
setForeground(Color color)
Set the foreground color of the components. |
void |
setSelected(boolean enable)
Select/Unselect ALL "boolean" components in
the grouping. |
void |
setText(String text)
Set the "text" for all of the components in the group. |
int |
smartAdd(Object o)
Smart add of zero or more components to the group. |
int |
smartRemove(Object o)
Smart remove of zero or more components to the group. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Grouping(String name)
Creates a "empty" group of components
addJComponent(javax.swing.JComponent),
smartAdd(java.lang.Object)| Method Detail |
|---|
public String getName()
Groupingspublic void addJComponent(JComponent c)
c - The JComponent component to add - must not be null.removeJComponent(javax.swing.JComponent),
smartAdd(java.lang.Object)public void removeJComponent(JComponent c)
c - The JComponent component to remove - must not be null.addJComponent(javax.swing.JComponent),
smartRemove(java.lang.Object)public int smartAdd(Object o)
This is a very flexible way to add elements to the grouping. You can pass any object type you want (or even null) and we will handle it to the best of our ability. Here are the types we currently handle:
JComponentaddJComponent(JComponent) method to add it to the grouping.EnumerationIteratorCollectionIterator for the collection and then recursively
call ourself (this handles most of the handy java.util
package classes - like Vector, Hashtable, List, etc).
o - The Object to process as described above.
smartRemove(java.lang.Object)public int smartRemove(Object o)
This is a very flexible way to remove elements from the grouping. You can pass any object type you want (or even null) and we will handle it to the best of our ability. Here are the types we currently handle:
JComponentremoveJComponent(JComponent) method to remove it from the
grouping.EnumerationIteratorCollectionIterator for the collection and then recursively
call ourself (this handles most of the handy java.util
package classes - like Vector, Hashtable, List, etc).
o - The Object to process as described above.
smartAdd(java.lang.Object)public void setEnabled(boolean enable)
components in the grouping.
This method will invoke the JComponent.setEnabled(boolean)
method for each component in the collection (lets you
enable/disable the entire group of components).
enable - Whether the component should be enabled or not.setSelected(boolean)public void setSelected(boolean enable)
components in
the grouping.
This method will invoke the setSelected(boolean) or setState(boolean) method for each JComponent in the grouping that has a "boolean" state
associated with it (such as AbstractButton derived
objects like the javax.swing.JCheckBoxMenuItem.
select - Whether the component should be selected (checked) or not.setEnabled(boolean)public void setForeground(Color color)
This method will invoke the JComponent.setForeground(java.awt.Color)
method for each component in the collection (lets you
change the foreground color for the entire group of components).
color - New color to set (or null if the components should use their
parent component's value)setBackground(java.awt.Color)public void setBackground(Color color)
This method will invoke the JComponent.setBackground(java.awt.Color)
method for each component in the collection (lets you
change the background color for the entire group of components).
color - New color to set (or null if the components should use their
parent value)setForeground(java.awt.Color)public void setText(String text)
This method will set the text value displayed for the
component(s) to the value specified. Currently, this only affects
components which are descendents of JTextComponent,
JLabel, or AbstractButton - this handles most of
the standard Swing items.
text - The new text to associate with the components.setEnabled(boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||