本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.setTextFieldFilter方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setTextFieldFilter方法的具体用法?Java TextField.setTextFieldFilter怎么用?Java TextField.setTextFieldFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.TextField
的用法示例。
在下文中一共展示了TextField.setTextFieldFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServerSetupMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
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);
}
示例2: MultiplayerConnectMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
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);
}
示例3: getTextField
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
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;
}
示例4: process
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final TextField actor,
final String rawAttributeData) {
@SuppressWarnings("unchecked") final ActorConsumer<Boolean, Character> filter = (ActorConsumer<Boolean, Character>) parser
.parseAction(rawAttributeData, Character.valueOf(' '));
if (filter == null) {
parser.throwErrorIfStrict(
"Text field filter attribute requires ID of an action that consumes a Character and returns a boolean or Boolean. Valid action not found for name: "
+ rawAttributeData);
return;
}
actor.setTextFieldFilter(new TextFieldFilter() {
@Override
public boolean acceptChar(final TextField textField, final char character) {
return filter.consume(character);
}
});
}
示例5: onInitUI
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
protected void onInitUI() {
Skin skin = GdxUISkin.instance().getDeafult();
input = new TextField("", skin);
ClickListener mClickListener = new ClickListener() {
public boolean keyDown (InputEvent event, int keycode) {
if(keycode == Keys.ENTER && !isHide()) {
if(!handleCmdString(input.getText())) {
//clear input
input.setText(null);
}
}
return true;
}
};
input.addCaptureListener(mClickListener);
input.setTextFieldFilter(new TextFieldFilter() {
@Override
public boolean acceptChar(TextField textField, char c) {
if(c == '`' || c == '~') {
hide();
return false;
}
return true;
}
});
label = new Label("", skin);
maxTmp = GdxUIConfig.instance().consoleMaxOutputLine;
input.setSize(getUIWidth()/2, 32);
input.setPosition(20, getUIHeight() * 0.25f);
addUI(input);
addUI(label);
skin = null;
}
示例6: ServerSetupMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
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);
}
示例7: process
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final TextField actor,
final String rawAttributeData) {
if (parser.parseBoolean(rawAttributeData, actor)) {
actor.setTextFieldFilter(new TextFieldFilter.DigitsOnlyFilter());
}
}
示例8: addTextField
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public void addTextField(String label, Object value, TextFieldListener lis) {
Label l = new Label(label, skin.get(LabelStyle.class));
table.add(l).minHeight(l.getMinHeight()).prefHeight(l.getPrefHeight());
TextField t = new TextField(String.valueOf(value), skin.get(TextFieldStyle.class));
t.setTextFieldListener(lis);
t.setDisabled(false);
t.setMaxLength(6);
if (value instanceof Number)
t.setTextFieldFilter((textField, c) -> Character.isDigit(c));
table.add(t).right().padLeft(1f);
table.row();
}
示例9: SingleplayerSaveCreateMenu
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
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);
}