|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.util.gui.CustomComboBoxRenderer
public class CustomComboBoxRenderer
Utility class which does the job of rendering items into a JComboBox when you just want to provide a different stringification of them than the one provided by the toString method.
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)
on an instance of the resulting
subclass.
Constructor Summary | |
---|---|
CustomComboBoxRenderer()
|
Method Summary | |
---|---|
Component |
getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean hasFocus)
|
Object |
getNullRepresentation()
Returns the representation for the null value. |
protected Object |
mapValue(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(Object nullRep)
Sets the representation for the null value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CustomComboBoxRenderer()
Method Detail |
---|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus)
getListCellRendererComponent
in interface ListCellRenderer
public void setNullRepresentation(Object nullRep)
mapValue(java.lang.Object)
will be called as usual
(which may itself do something with the null).
nullRep
- null representationpublic Object getNullRepresentation()
protected Object mapValue(Object value)
The default implementation just returns the value itself
value
- value to map
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |