Package net.sf.freecol.client.gui.plaf
Class FreeColComboBoxRenderer<T>
- java.lang.Object
-
- net.sf.freecol.client.gui.plaf.FreeColComboBoxRenderer<T>
-
- All Implemented Interfaces:
javax.swing.ListCellRenderer<T>
,javax.swing.plaf.UIResource
- Direct Known Subclasses:
AbstractUnitOptionUI.AbstractUnitRenderer
,AbstractUnitOptionUI.RoleRenderer
,ConfirmDeclarationDialog.EnumRenderer
,FindSettlementPanel.SettlementRenderer
,ModOptionUI.BoxRenderer
,ModOptionUI.ModOptionRenderer
,SelectDestinationDialog.LocationRenderer
,UnitTypeOptionUI.ChoiceRenderer
public class FreeColComboBoxRenderer<T> extends java.lang.Object implements javax.swing.ListCellRenderer<T>, javax.swing.plaf.UIResource
AListCellRenderer
to be used byFreeColListUI
andJComboBox
es that displayObjectWithId
values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
FreeColComboBoxRenderer.NormalComponent
private static class
FreeColComboBoxRenderer.SelectedComponent
-
Field Summary
Fields Modifier and Type Field Description private boolean
localize
private static java.util.logging.Logger
logger
private FreeColComboBoxRenderer.NormalComponent
NORMAL_COMPONENT
private java.lang.String
prefix
private FreeColComboBoxRenderer.SelectedComponent
SELECTED_COMPONENT
-
Constructor Summary
Constructors Constructor Description FreeColComboBoxRenderer()
Creates a newFreeColComboBoxRenderer
instance with an empty prefix.FreeColComboBoxRenderer(java.lang.String prefix)
Creates a newFreeColComboBoxRenderer
instance with a given prefix.FreeColComboBoxRenderer(java.lang.String prefix, boolean localize)
Creates a newFreeColComboBoxRenderer
instance with a given prefix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Component
getListCellRendererComponent(javax.swing.JList<? extends T> list, T value, int index, boolean isSelected, boolean hasFocus)
Returns aListCellRenderer
for the givenJList
.protected void
setLabelValues(javax.swing.JLabel c, T value)
Set the text to place in a label.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
SELECTED_COMPONENT
private final FreeColComboBoxRenderer.SelectedComponent SELECTED_COMPONENT
-
NORMAL_COMPONENT
private final FreeColComboBoxRenderer.NormalComponent NORMAL_COMPONENT
-
prefix
private final java.lang.String prefix
-
localize
private boolean localize
-
-
Constructor Detail
-
FreeColComboBoxRenderer
public FreeColComboBoxRenderer()
Creates a newFreeColComboBoxRenderer
instance with an empty prefix.
-
FreeColComboBoxRenderer
public FreeColComboBoxRenderer(java.lang.String prefix)
Creates a newFreeColComboBoxRenderer
instance with a given prefix.- Parameters:
prefix
- aString
value
-
FreeColComboBoxRenderer
public FreeColComboBoxRenderer(java.lang.String prefix, boolean localize)
Creates a newFreeColComboBoxRenderer
instance with a given prefix.- Parameters:
prefix
- aString
valuelocalize
- aboolean
value
-
-
Method Detail
-
getListCellRendererComponent
public java.awt.Component getListCellRendererComponent(javax.swing.JList<? extends T> list, T value, int index, boolean isSelected, boolean hasFocus)
Returns aListCellRenderer
for the givenJList
.- Specified by:
getListCellRendererComponent
in interfacejavax.swing.ListCellRenderer<T>
- Parameters:
list
- TheJList
.value
- The list cell.index
- The index in the list.isSelected
-true
if the given list cell is selected.hasFocus
-false
if the given list cell has the focus.- Returns:
- The
ListCellRenderer
-
setLabelValues
protected void setLabelValues(javax.swing.JLabel c, T value)
Set the text to place in a label.- Parameters:
c
- TheJLabel
to assign.value
- The object to derive a text value from.
-
-