|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objectwave.viewUtility.VectorToButtons
Provides the ability to create a vector of buttons from a vector of data. The method getButtons() will return the buttons generated, and getPanel() will return the buttons contained in a JPanel using a vertically-oriented GridLayout. Note that the buttons and the panel will automatically update with calls to the various setXxx() methods. The same panel will always be returned for a given instance of this class, while the buttons array will change if and only if the data vector is changed. Displaying Labels:
The labels for the buttons can be specified if three different ways. A vector of strings can be provided via the setLabels() method, a StringifyIF instance can be provided, or the toString() value of each data element can be used. If a vector of strings is provided, then that will be used over all other methods. Otherwise, if a stringifier is defined, then it will be used. If all else failed the toString() values are used.
Customizing the Buttons' Appearance
The font of all of the buttons can be specified simply by calling
setFont(). Additionally, the layout can be modified by calling
getPanel().setLayout(someLayoutManager). This should be followed by
getPanel().revalidate() if the panel may currently be visible.
Specifying Button Behavior
A common behavior can be associated with all of the buttons by calling
setAction() with some ActionIF object. This interface's single method,
public void performAction(Object), is passed the data element
associated with the button that was clicked. This single ActionIF
object is applied to all buttons. If this is not desired for a given
button, then simply call removeListener(int), passing the index of the
given button.
Constructor Summary | |
VectorToButtons()
Constructors: |
|
VectorToButtons(java.util.Vector data)
|
|
VectorToButtons(java.util.Vector data,
java.util.Vector strings)
|
Method Summary | |
protected void |
action(java.lang.Object source)
|
javax.swing.JButton[] |
getButtons()
|
java.util.Vector |
getData()
|
java.awt.Font |
getFont()
|
StringifyIF |
getLabelifier()
|
java.util.Vector |
getLabels()
|
javax.swing.JPanel |
getPanel()
|
static void |
main(java.lang.String[] args)
The rest of this class definition is for testing: |
void |
removeListener(int index)
Remove the index'th button's action listener. |
void |
setAction(ActionIF act)
|
void |
setData(java.util.Vector data)
|
void |
setFont(java.awt.Font f)
|
void |
setLabels(java.util.Vector strings)
|
void |
setStringifier(StringifyIF s)
|
protected void |
updateAll()
Remake the button vector. |
protected void |
updateFont()
|
protected void |
updateLabels()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public VectorToButtons()
public VectorToButtons(java.util.Vector data)
public VectorToButtons(java.util.Vector data, java.util.Vector strings)
Method Detail |
protected void action(java.lang.Object source)
public javax.swing.JButton[] getButtons()
public java.util.Vector getData()
public java.awt.Font getFont()
public StringifyIF getLabelifier()
public java.util.Vector getLabels()
public javax.swing.JPanel getPanel()
public static void main(java.lang.String[] args)
public void removeListener(int index)
public void setAction(ActionIF act)
public void setData(java.util.Vector data)
public void setFont(java.awt.Font f)
public void setLabels(java.util.Vector strings)
public void setStringifier(StringifyIF s)
protected void updateAll()
protected void updateFont()
protected void updateLabels()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |