Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.TextField#setMessageText()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.TextField#setMessageText() .
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: ServerSetupMenu.java From Cubes with MIT License | 6 votes |
public ServerSetupMenu(final Save save) { super(); title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class)); saveLabel = new Label(Localization.get("menu.server.save", save.name), skin); saveLabel.setAlignment(Align.center); port = new TextField("", skin); port.setMessageText(Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT))); port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); start = new TextButton(Localization.get("menu.server.start"), skin); back = MenuTools.getBackButton(this); start.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT) : Integer.parseInt(port.getText()); Adapter.setMenu(new ServerRunningMenu(save, p)); } }); stage.addActor(title); stage.addActor(saveLabel); stage.addActor(port); stage.addActor(start); stage.addActor(back); }
Example 2
Source File: MultiplayerConnectMenu.java From Cubes with MIT License | 6 votes |
public MultiplayerConnectMenu() { super(); title = new Label(Localization.get("menu.multiplayer.title"), skin.get("title", Label.LabelStyle.class)); address = new TextField("", skin); address.setMessageText(Localization.get("menu.multiplayer.address")); port = new TextField("", skin); port.setMessageText(Localization.get("menu.multiplayer.port", 24842)); //Not "Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)" because the port is set on the server port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); connect = new TextButton(Localization.get("menu.multiplayer.connect"), skin); back = MenuTools.getBackButton(this); connect.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Adapter.setMenu(new MultiplayerLoadingMenu(address.getText().isEmpty() ? "localhost" : address.getText(), port.getText().isEmpty() ? 24842 : Integer.parseInt(port.getText()))); } }); stage.addActor(title); stage.addActor(address); stage.addActor(port); stage.addActor(connect); stage.addActor(back); }
Example 3
Source File: IntegerSetting.java From Cubes with MIT License | 6 votes |
private TextField getTextField(VisualSettingManager visualSettingManager) { final TextField textField = new TextField(i + "", visualSettingManager.getSkin()); textField.addListener(new EventListener() { @Override public boolean handle(Event event) { if (!(event instanceof SettingsMenu.SaveEvent)) return false; try { int n = Integer.parseInt(textField.getText()); if (hasRange && (n < rangeStart || n > rangeEnd)) { throw new NumberFormatException(); } else { set(n); return true; } } catch (Exception e) { textField.setText(i + ""); return false; } } }); textField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); if (hasRange) textField.setMessageText("(" + rangeStart + "-" + rangeEnd + ")"); return textField; }
Example 4
Source File: SingleplayerSaveCreateMenu.java From Cubes with MIT License | 4 votes |
public SingleplayerSaveCreateMenu() { super(); title = new Label(Localization.get("menu.singleplayer.create.title"), skin.get("title", Label.LabelStyle.class)); name = new TextField("", skin); name.setMessageText(Localization.get("menu.singleplayer.create.name")); name.setTextFieldFilter(new TextField.TextFieldFilter() { @Override public boolean acceptChar(TextField textField, char c) { return c >= 0x20 && c < 0x7F; } }); generator = new SelectBox<SaveTypeDisplay>(skin); String[] types = GeneratorManager.ids(); SaveTypeDisplay[] display = new SaveTypeDisplay[types.length]; for (int i = 0; i < types.length; i++) { display[i] = new SaveTypeDisplay(types[i]); } generator.setItems(display); mode = new SelectBox<Gamemode>(skin); mode.setItems(Gamemode.values()); seed = new TextField("", skin); seed.setMessageText(Localization.get("menu.singleplayer.create.seed")); start = new TextButton(Localization.get("menu.singleplayer.create.start"), skin); back = MenuTools.getBackButton(this); start.addListener(startListener = new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Adapter.setMenu(new SingleplayerLoadingMenu(ClientSaveManager.createSave(name.getText(), generator.getSelected().id, mode.getSelected(), seed.getText()))); } }); stage.addActor(title); stage.addActor(name); stage.addActor(generator); stage.addActor(mode); stage.addActor(seed); stage.addActor(start); stage.addActor(back); }