|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.visuals.CheckBoxList
public class CheckBoxList
A component that allows the user to select one or more objects from a
list by using checkboxes in place of labels.
A separate model, ListModel
, represents the contents
of the list. It's easy to display an array or vector of objects, using
a CheckBoxList
constructor that builds a ListModel
instance for you:
// Create a CheckBoxList that displays the strings in data[] String[] data = {"one", "two", "three", "four"}; CheckBoxList dataList = new CheckBoxList(data); // The value of the CheckBoxList model property is an object that provides // a read-only view of the data. It was constructed automatically. for(int i = 0; i < dataList.getModel().getSize(); i++) { System.out.println(dataList.getModel().getElementAt(i)); } // Create a CheckBoxList that displays the superclass of CheckBoxList.class. // We store the superclasses in a java.util.Vector. Vector superClasses = new Vector(); Class rootClass = javax.swing.CheckBoxList.class; for(Class cls = rootClass; cls != null; cls = cls.getSuperclass()) { superClasses.addElement(cls); } CheckBoxList classList = new CheckBoxList(superClasses);
CheckBoxList
doesn't support scrolling directly.
To create a scrolling
list you make the CheckBoxList
the viewport view of a
JScrollPane
. For example:
JScrollPane scrollPane = new JScrollPane(dataList); // Or in two steps: JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().setView(dataList);
By default the CheckBoxList
selection model allows any
combination of items to be selected at a time, using the constant
MULTIPLE_INTERVAL_SELECTION
.
The selection state is actually managed
by a separate delegate object, an instance of
ListSelectionModel
.
However CheckBoxList
provides convenient properties for
managing the selection.
String[] data = {"one", "two", "three", "four"}; CheckBoxList dataList = new CheckBoxList(data); dataList.setSelectedIndex(1); // select "two" dataList.getSelectedValues(); // returns "two" dataList.setSelectedIndex(2); // select "three" dataList.getSelectedValues(); // returns "two","three" dataList.setSelectedIndex(1); // select "two" which deselects it since it was already selected dataList.getSelectedValues(); // returns "three"
Field Summary | |
---|---|
static java.lang.String |
RB_KEY
|
Constructor Summary | |
---|---|
CheckBoxList()
Constructs a CheckBoxList with an empty model. |
|
CheckBoxList(javax.swing.ListModel dataModel)
Constructs a CheckBoxList that displays the elements in the
specified, non-null model. |
|
CheckBoxList(java.lang.Object[] listData)
Constructs a CheckBoxList that displays the elements in the specified
array. |
|
CheckBoxList(java.util.Vector listData)
Constructs a CheckBoxList that displays the elements in the specified
Vector . |
Method Summary | |
---|---|
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this CheckBoxList. |
boolean |
isBorderPaintedFlat()
Returns whether the checkbox border is painted flat. |
void |
setBorderPaintedFlat(boolean b)
Sets whether the border should be painted flat. |
void |
setSelectedIndices(int[] indices)
Selects a set of cells. |
Field Detail |
---|
public static final java.lang.String RB_KEY
Constructor Detail |
---|
public CheckBoxList(javax.swing.ListModel dataModel)
CheckBoxList
that displays the elements in the
specified, non-null model. All CheckBoxList
constructors
delegate to this one.
dataModel
- the data model for this list
java.lang.IllegalArgumentException
- if dataModel
is null
public CheckBoxList(java.lang.Object[] listData)
CheckBoxList
that displays the elements in the specified
array. This constructor just delegates to the ListModel
constructor.
listData
- the array of Objects to be loaded into the data modelpublic CheckBoxList(java.util.Vector listData)
CheckBoxList
that displays the elements in the specified
Vector
. This constructor just delegates to the
ListModel
constructor.
listData
- the Vector
to be loaded into the data modelpublic CheckBoxList()
CheckBoxList
with an empty model.
Method Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this CheckBoxList.
public void setSelectedIndices(int[] indices)
setSelectedIndices
in class javax.swing.JList
indices
- an array of the indices of the cells to selectListSelectionModel.setSelectionInterval(int, int)
public void setBorderPaintedFlat(boolean b)
b
- if true, the border is painted flat.public boolean isBorderPaintedFlat()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |