Package net.sf.freecol.client.gui.option
Class OptionUI<T extends Option<?>>
- java.lang.Object
-
- net.sf.freecol.client.gui.option.OptionUI<T>
-
- All Implemented Interfaces:
OptionUpdater
- Direct Known Subclasses:
AbstractUnitOptionUI,AudioMixerOptionUI,BooleanOptionUI,FileOptionUI,FreeColActionUI,IntegerOptionUI,LanguageOptionUI,ListOptionUI,ModOptionUI,SelectOptionUI,SliderOptionUI,StringOptionUI,TextOptionUI,UnitTypeOptionUI
public abstract class OptionUI<T extends Option<?>> extends java.lang.Object implements OptionUpdater
This class provides common methods for various Option UIs.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract javax.swing.JComponentgetComponent()Get theComponentused to set the value of the Option.javax.swing.JLabelgetJLabel()javax.swing.ListCellRenderergetListCellRenderer()Get a ListCellRenderer suitable for the wrapped Option.TgetOption()static OptionUIgetOptionUI(GUI gui, Option option, boolean editable)Get an option UI for a given option.protected voidinitialize()Set up component.booleanisEditable()private booleanisEnabled()abstract voidreset()Reset the value of the UI's component from the Option.voidsetEditable(boolean newEditable)voidsetEnabler(BooleanOptionUI enabler)protected voidsetLabel(javax.swing.JLabel label)voidsetOption(T newOption)abstract voidupdateOption()Update the value of the Option from the UI's component.
-
-
-
Field Detail
-
editable
private boolean editable
Whether the Option should be editable.
-
label
private javax.swing.JLabel label
The label to use for the Option.
-
enabler
private BooleanOptionUI enabler
-
-
Constructor Detail
-
OptionUI
protected OptionUI(T option, boolean editable)
Constructor.- Parameters:
option- TheOptionto display.editable- True if the option should be editable.
-
-
Method Detail
-
initialize
protected void initialize()
Set up component.
-
getOption
public final T getOption()
-
setOption
public final void setOption(T newOption)
-
isEditable
public final boolean isEditable()
-
isEnabled
private boolean isEnabled()
-
setEditable
public final void setEditable(boolean newEditable)
-
setEnabler
public void setEnabler(BooleanOptionUI enabler)
-
getJLabel
public javax.swing.JLabel getJLabel()
-
setLabel
protected void setLabel(javax.swing.JLabel label)
-
getListCellRenderer
public javax.swing.ListCellRenderer getListCellRenderer()
Get a ListCellRenderer suitable for the wrapped Option.- Returns:
- A suitable ListCellRenderer.
-
getComponent
public abstract javax.swing.JComponent getComponent()
Get theComponentused to set the value of the Option.- Returns:
- a
JComponentvalue
-
updateOption
public abstract void updateOption()
Update the value of the Option from the UI's component.- Specified by:
updateOptionin interfaceOptionUpdater
-
reset
public abstract void reset()
Reset the value of the UI's component from the Option.- Specified by:
resetin interfaceOptionUpdater
-
-