javax.swing.ListCellRenderer
public class CustomComboBoxRenderer
extends java.lang.Object
implements javax.swing.ListCellRenderer
You would use this class by providing an implementation of the
mapValue(java.lang.Object)
method and class by calling
JComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)
on an instance of the resulting
subclass.
Constructor | Description |
---|---|
CustomComboBoxRenderer() |
Modifier and Type | Method | Description |
---|---|---|
java.awt.Component |
getListCellRendererComponent(javax.swing.JList list,
java.lang.Object value,
int index,
boolean isSelected,
boolean hasFocus) |
|
java.lang.Object |
getNullRepresentation() |
Returns the representation for the null value.
|
protected java.lang.Object |
mapValue(java.lang.Object value) |
Turns an object which might be found in the ComboBox itself into
an object that can be rendered by a standard combobox renderer.
|
void |
setNullRepresentation(java.lang.Object nullRep) |
Sets the representation for the null value.
|
public java.awt.Component getListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected, boolean hasFocus)
getListCellRendererComponent
in interface javax.swing.ListCellRenderer
public void setNullRepresentation(java.lang.Object nullRep)
mapValue(java.lang.Object)
will be called as usual
(which may itself do something with the null).nullRep
- null representationpublic java.lang.Object getNullRepresentation()
protected java.lang.Object mapValue(java.lang.Object value)
The default implementation just returns the value itself
value
- value to mapCopyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.