|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
com.citra.component.CheckComboBox
public class CheckComboBox
CheckComboBox is a JComboBox that allows multiple values to be selected, instead of just one, via checkboxes.
The selected values can be retrieved with getSelectedValues
and can also be assigned with
setSelectedValues
.
CheckComboBox uses its own list cell renderer in order to display a checkbox on every row of the box's popup menu.
It also assigns a list cell renderer wrapper under the box's normal renderer, which can be retrieved with the
getRealRenderer
method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComboBox |
---|
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected JPanel |
buttonPanel
the panel that contains buttons for accepting/canceling the current selection |
protected JButton |
cancelButton
the button that cancels the current selection |
protected boolean |
multipleSelection
controls whether the combobox allows multiple values to be selected |
protected JButton |
okButton
the button that accepts the current selection |
Fields inherited from class javax.swing.JComboBox |
---|
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
CheckComboBox()
Constructs a CheckComboBox. |
Method Summary | |
---|---|
void |
addSelection(Object selectedValue)
Adds a given object to the checkbox selection. |
void |
clearSelection()
Clears all of the selected checkboxes. |
JButton |
getCancelButton()
Returns the button that cancels the current selection. |
protected int |
getCheckBoxState(TreePath path)
Retrieves the state of the check box for a given path. |
boolean |
getMultipleSelection()
Determines whether the combobox allows the selection of multiple values via checkboxes. |
JButton |
getOkButton()
Returns the button that accepts the current selection. |
ListCellRenderer |
getRealRenderer()
Returns the combo box's cell renderer used for rendering the list after the checkbox part. |
List |
getSelectedValues()
Retrieves the list of selected values. |
String |
getValue(Object selectedValue)
Formats the selected value into a string. |
void |
removeSelection(Object selectedValue)
Removes a given object from the checkbox selection. |
void |
selectAll()
Adds all values to the checkbox selection. |
void |
setEditable(boolean editable)
Determines whether the JComboBox field is editable. |
void |
setModel(ComboBoxModel model)
Sets the data model that the JComboBox uses to obtain
the list of items. |
void |
setMultipleSelection(boolean multipleSelection)
Determines whether the combobox allows the selection of multiple values via checkboxes. |
void |
setPopupVisible(boolean show)
Sets the visibility of the popup. |
void |
setRenderer(ListCellRenderer aRenderer)
Sets the renderer that paints the list items and the item selected from the list in the JComboBox field. |
void |
setSelectedValues(List values)
Assigns a list of values to the checkbox selection. |
void |
updateUI()
Resets the UI property to a value from the current look and feel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean multipleSelection
protected JPanel buttonPanel
protected JButton okButton
protected JButton cancelButton
Constructor Detail |
---|
public CheckComboBox()
Method Detail |
---|
public void addSelection(Object selectedValue)
selectedValue
- the value to selectpublic void clearSelection()
public JButton getCancelButton()
protected int getCheckBoxState(TreePath path)
path
- the path to check
public boolean getMultipleSelection()
public JButton getOkButton()
public ListCellRenderer getRealRenderer()
public List getSelectedValues()
public String getValue(Object selectedValue)
selectedValue
- the value to format
public void removeSelection(Object selectedValue)
selectedValue
- the value to removepublic void selectAll()
public void setEditable(boolean editable)
JComboBox
field is editable.
An editable JComboBox
allows the user to type into the
field or selected an item from the list to initialize the field,
after which it can be edited. (The editing affects only the field,
the list item remains intact.) A non editable JComboBox
displays the selected item in the field,
but the selection cannot be modified.
setEditable
in class JComboBox
editable
- a boolean value, where true indicates that the
field is editablepublic void setModel(ComboBoxModel model)
JComboBox
uses to obtain
the list of items.
setModel
in class JComboBox
model
- the ComboBoxModel
that provides the
displayed list of itemspublic void setMultipleSelection(boolean multipleSelection)
multipleSelection
- true, if selection of multiple values is allowed, false otherwisepublic void setPopupVisible(boolean show)
setPopupVisible
in class JComboBox
public void setRenderer(ListCellRenderer aRenderer)
The default renderer displays a string or an icon. Other renderers can handle graphic images and composite items.
To display the selected item,
aRenderer.getListCellRendererComponent
is called, passing the list object and an index of -1.
setRenderer
in class JComboBox
aRenderer
- the ListCellRenderer
that
displays the selected itemJComboBox.setEditor(javax.swing.ComboBoxEditor)
public void setSelectedValues(List values)
values
- the values to assignpublic void updateUI()
updateUI
in class JComboBox
JComponent.updateUI()
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |