 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.combobox;
32 import java.awt.Component;
33 import java.util.ArrayList;
34 import java.util.Comparator;
35 import java.util.Iterator;
36 import java.util.List;
37 import javax.swing.JLabel;
38 import javax.swing.JList;
39 import org.jetbrains.annotations.NotNull;
40 import org.jetbrains.annotations.Nullable;
73 public void changed() {
90 super(tooltipManager, elementListener, name,
label, guiFactory);
113 @Nullable
final List<Integer>
model;
114 if (option ==
null) {
117 model =
new ArrayList<>();
118 final List<String> choices =
new ArrayList<>(option.
getChoices().values());
119 for (
int i = 0; i < choices.size(); i++) {
122 model.sort(Comparator.comparing(choices::get));
130 protected Component
getListCellRendererComponent(@NotNull
final JList<? extends Integer> list, @Nullable
final Integer value,
final int index,
final boolean selected,
final boolean cellHasFocus) {
133 if (option ==
null || value ==
null) {
136 final Iterator<String> it = option.
getChoices().values().iterator();
137 for (
int i = 0; i < value; i++) {
142 text = it.hasNext() ? it.next() :
"";
void updateSelectedItem(@Nullable final Integer item)
void addListener(@NotNull final NewCharModelListener listener)
Adds a listener to notify of changes.
int getOptionIndex()
Return the selected character option.
Component getListCellRendererComponent(@NotNull final JList<? extends Integer > list, @Nullable final Integer value, final int index, final boolean selected, final boolean cellHasFocus)
final GUILabelLog label
The GUILog to update or.
void updateModel()
Updates the combo box model to reflect the current starting map list of newCharModel.
Interface for listeners interested in NewCharModel related changes.
A GUIComboBox that shows character creation options.
void updateSelectedItem()
Called whenever the selected item has changed.
A GUIElement that displays a combo box.
GUICharOptionsComboBox(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final NewCharModel newCharModel, @Nullable final GUILabelLog label, @NotNull final GuiFactory guiFactory)
Creates a new instance.
A choice for character creation.
static final long serialVersionUID
The serial version UID.
final DefaultComboBoxModel< T > model
The model for comboBox.
final JLabel renderer
The JLabel that displays the list values.
final NewCharModelListener newCharModelListener
The listener attached to newCharModel.
General information for creating new characters.
void removeListener(@NotNull final NewCharModelListener listener)
Removes a listener to be notified of changes.
Factory for creating Gui instances.
final NewCharModel newCharModel
The NewCharModel that is shown.
Choice getOption()
Returns the character options.
void setSelectedItem( @NotNull final T item)
Updates the selected item.
void setOptionIndex(final int optionIndex)
Sets the selected character option.
Map< String, String > getChoices()
Returns the choices.
A gui element implementing a static text field which may contain media tags.
String getDescription(@Nullable final Integer item)
Listener for GUIElement related events.