Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.SelectBox#setItems()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.SelectBox#setItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyTable.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void addProperty(String name, String selected, String[] value) {
	table.row();
	table.add(new Label(name, skin)).expandX().left();

	SelectBox<String> sb = new SelectBox<String>(skin);
	sb.setItems(value);
	if (selected != null)
		sb.setSelected(selected);
	sb.setName(name);
	table.add(sb).expandX().left();

	sb.addListener(new ChangeListener() {

		@SuppressWarnings("unchecked")
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			updateModel(actor.getName(), ((SelectBox<String>) actor).getSelected());
		}
	});
}
 
Example 2
Source File: DropDownSetting.java    From Cubes with MIT License 6 votes vote down vote up
@Override
public Actor getActor(final String settingName, VisualSettingManager visualSettingManager) {
  final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin()) {
    @Override
    protected String toString(String s) {
      return Settings.getLocalisedSettingName(settingName + "." + s);
    }
  };
  selectBox.setItems(options);
  selectBox.setSelected(selected);
  selectBox.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
      if (!(event instanceof SettingsMenu.SaveEvent)) return false;
      set(selectBox.getSelected());
      return true;
    }
  });
  return selectBox;
}
 
Example 3
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public static SelectBox<String> newSelectBox (String[] items, ChangeListener listener) {
	SelectBox<String> sb = new SelectBox<String>(Art.scrSkin);
	if (listener != null) {
		sb.addListener(listener);
	}

	sb.setItems(items);
	return sb;
}
 
Example 4
Source File: MainListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void loadClasses(SelectBox classSelectBox) {
    Array names = new Array<>();
    for (Class clazz : Main.BASIC_CLASSES) {
        names.add(clazz.getSimpleName());
    }
    for (CustomClass customClass : main.getJsonData().getCustomClasses()) {
        names.add(customClass);
    }
    classSelectBox.setItems(names);
}
 
Example 5
Source File: MainListener.java    From skin-composer with MIT License 5 votes vote down vote up
@Override
public void loadStyles(SelectBox classSelectBox, SelectBox styleSelectBox) {
    int selection = classSelectBox.getSelectedIndex();
    if (selection < Main.BASIC_CLASSES.length) { 
        Class selectedClass = Main.BASIC_CLASSES[selection];
        styleSelectBox.setItems(jsonData.getClassStyleMap().get(selectedClass));
        styleSelectBox.setSelectedIndex(0);
    } else {
        CustomClass customClass = (CustomClass) classSelectBox.getSelected();
        styleSelectBox.setItems(customClass.getStyles());
    }
}