本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.setMessageText方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setMessageText方法的具体用法?Java TextField.setMessageText怎么用?Java TextField.setMessageText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.TextField
的用法示例。
在下文中一共展示了TextField.setMessageText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: parseTextField
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public static void parseTextField(TextField textField, XmlReader.Element element){
String text = element.get("text","");
String messageText = element.get("messageText","");
textField.setText(text);
textField.setMessageText(messageText);
attr2TextField(textField);
}
示例5: AssetTextFieldImpl
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
AssetTextFieldImpl(LibGdxAssetCache cache, String initialFieldText, TextFieldDescriptor textFieldDescriptor) {
this.cache = cache;
this.textFieldDescriptor = textFieldDescriptor;
textFont = cache.getFont(textFieldDescriptor.getFont());
hintFont = cache.getFont(textFieldDescriptor.getMessageFont());
backgroundTexture = cache.getPixMapTexture(Color.WHITE);
textField = new TextField(initialFieldText, createTextFieldStyle());
textField.setMessageText(textFieldDescriptor.getHintText());
}
示例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: RoomChatPanel
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RoomChatPanel (float w, float h) {
super();
content = new StringBuilder();
chatprint= new Label(content,Resources._skin);
inputfield = new TextField("",Resources._skin);
inputfield.setWidth(w);
inputfield.setMaxLength(max_char_per_mess);
inputfield.setMessageText("Enter to send ...");
inputfield.addListener(new InputListener() {
RoomChat__ chat = new RoomChat__();
public boolean keyTyped(InputEvent event, char character) {
if ( character == 13) {
chat.content = inputfield.getText().getBytes();
Resources._nclient.sendRoomChat(chat);
inputfield.setText("");
}
return false;
};
} );
scrpane = new ScrollPane(chatprint, Resources._skin);
scrpane.setSize(w,h-inputfield.getHeight()-1);
scrpane.setFadeScrollBars(false);
scrpane.setPosition(0,inputfield.getHeight()+1);
addActor(scrpane);
addActor(inputfield);
this.h = h;
this.w = w;
}
示例8: 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);
}
示例9: 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) {
actor.setMessageText(parser.parseString(rawAttributeData, actor));
}
示例10: show
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), new TextureAtlas("ui/atlas.pack"));
table = new Table(skin);
table.setFillParent(true);
final CheckBox vSyncCheckBox = new CheckBox("vSync", skin,"default");
vSyncCheckBox.setChecked(vSync());
final TextField levelDirectoryInput = new TextField(levelDirectory().path(), skin,"default"); // creating a new TextField with the current level directory already written in it
levelDirectoryInput.setMessageText("Nivel de directorio"); // set the text to be shown when nothing is in the TextField
final TextButton back = new TextButton("Atras", skin,"default");
back.pad(10);
ClickListener buttonHandler = new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
//AssetLoaderSpace.music_menu.stop();
// event.getListenerActor() returns the source of the event, e.g. a button that was clicked
if(event.getListenerActor() == vSyncCheckBox) {
// save vSync
Gdx.app.getPreferences(LittleNibolas.TITLE).putBoolean("vsync", vSyncCheckBox.isChecked());
// set vSync
Gdx.graphics.setVSync(vSync());
Gdx.app.log(LittleNibolas.TITLE, "vSync " + (vSync() ? "enabled" : "disabled"));
} else if(event.getListenerActor() == back) {
// save level directory
String actualLevelDirectory = levelDirectoryInput.getText().trim().equals("") ? Gdx.files.getExternalStoragePath() + LittleNibolas.TITLE + "/levels" : levelDirectoryInput.getText().trim(); // shortened form of an if-statement: [boolean] ? [if true] : [else] // String#trim() removes spaces on both sides of the string
Gdx.app.getPreferences(LittleNibolas.TITLE).putString("NivelDeDirectorio", actualLevelDirectory);
// save the settings to preferences file (Preferences#flush() writes the preferences in memory to the file)
Gdx.app.getPreferences(LittleNibolas.TITLE).flush();
Gdx.app.log(LittleNibolas.TITLE, "Configuración guardada");
stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {
@Override
public void run() {
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu(game));
}
})));
}
}
};
vSyncCheckBox.addListener(buttonHandler);
back.addListener(buttonHandler);
// putting everything in the table
table.add(new Label("Opciones", skin, "big")).spaceBottom(50).colspan(3).expandX().row();
table.add();
table.add("Nivel de directorio");
table.add().row();
table.add(vSyncCheckBox).top().expandY();
table.add(levelDirectoryInput).top().fillX();
table.add(back).bottom().right();
stage.addActor(table);
stage.addAction(sequence(moveTo(0, stage.getHeight()), moveTo(0, 0, .5f))); // coming in from top animation
}
示例11: show
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
@Override
public void show() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), new TextureAtlas("ui/atlas.pack"));
table = new Table(skin);
table.setFillParent(true);
final CheckBox vSyncCheckBox = new CheckBox("vSync", skin,"default");
vSyncCheckBox.setChecked(vSync());
final TextField levelDirectoryInput = new TextField(levelDirectory().path(), skin,"default"); // creating a new TextField with the current level directory already written in it
levelDirectoryInput.setMessageText("Nivel de directorio"); // set the text to be shown when nothing is in the TextField
final TextButton back = new TextButton("Atras", skin,"default");
back.pad(10);
ClickListener buttonHandler = new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
//AssetLoaderSpace.music_menu.stop();
// event.getListenerActor() returns the source of the event, e.g. a button that was clicked
if(event.getListenerActor() == vSyncCheckBox) {
// save vSync
Gdx.app.getPreferences(LittleNibolas.TITLE).putBoolean("vsync", vSyncCheckBox.isChecked());
// set vSync
Gdx.graphics.setVSync(vSync());
Gdx.app.log(LittleNibolas.TITLE, "vSync " + (vSync() ? "enabled" : "disabled"));
} else if(event.getListenerActor() == back) {
// save level directory
String actualLevelDirectory = levelDirectoryInput.getText().trim().equals("") ? Gdx.files.getExternalStoragePath() + LittleNibolas.TITLE + "/levels" : levelDirectoryInput.getText().trim(); // shortened form of an if-statement: [boolean] ? [if true] : [else] // String#trim() removes spaces on both sides of the string
Gdx.app.getPreferences(LittleNibolas.TITLE).putString("NivelDeDirectorio", actualLevelDirectory);
// save the settings to preferences file (Preferences#flush() writes the preferences in memory to the file)
Gdx.app.getPreferences(LittleNibolas.TITLE).flush();
Gdx.app.log(LittleNibolas.TITLE, "Configuración guardada");
stage.addAction(sequence(moveTo(0, stage.getHeight(), .5f), run(new Runnable() {
@Override
public void run() {
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
}
})));
}
}
};
vSyncCheckBox.addListener(buttonHandler);
back.addListener(buttonHandler);
// putting everything in the table
table.add(new Label("Opciones", skin, "big")).spaceBottom(50).colspan(3).expandX().row();
table.add();
table.add("Nivel de directorio");
table.add().row();
table.add(vSyncCheckBox).top().expandY();
table.add(levelDirectoryInput).top().fillX();
table.add(back).bottom().right();
stage.addActor(table);
stage.addAction(sequence(moveTo(0, stage.getHeight()), moveTo(0, 0, .5f))); // coming in from top animation
}
示例12: RegistrationPanel
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public RegistrationPanel() {
final TextField userid_field = new TextField("", Resources._skin);
userid_field.setMaxLength(Settings._max_reister_userid_length);
userid_field.setMessageText("user id");
final TextField username_field = new TextField("", Resources._skin);
username_field.setMaxLength(Settings._max_reister_username_length);
username_field.setMessageText("username");
final TextField password_field = new TextField( "", Resources._skin);
password_field.setPasswordMode(true);
password_field.setPasswordCharacter('*');
password_field.setMaxLength(30);
password_field.setMessageText("password");
TextButton register_button = new TextButton("Register", Resources._skin);
register_button.setPosition(180, 320);
register_button.addListener(new ClickListener(){
RegistrationInfo__ ri = new RegistrationInfo__();
float last_try;
@Override
public void clicked(InputEvent event, float x, float y) {
if ( current_time - last_try > 1 ) {
String raw_username = username_field.getText();
String raw_userid = userid_field.getText();
String raw_password = password_field.getText();
if ( raw_username.length() < Settings._min_reister_username_length ) {
Resources._messbar.setText("Error: username is too short, needs at least "+(Settings._min_reister_username_length+1)+" characters");
return;
}
if ( raw_password.length() < Settings._min_reister_password_length ) {
Resources._messbar.setText("Error: password is too short, needs at least "+(Settings._min_reister_password_length+1)+" characters");
return;
}
if ( raw_password.length() < Settings._min_reister_userid_length ) {
Resources._messbar.setText("Error: user id is too short, needs at least "+(Settings._min_reister_password_length+1)+" characters");
return;
}
ri.username = raw_username.getBytes();
ri.one_time_hashed_password = Resources._hash.sha1(raw_password).getBytes();
ri.userid = raw_userid.getBytes();
Resources._nclient.sendRegistrationInfo(ri);
last_try = current_time;
} else {
Resources._messbar.setText("Please slow down click speed");
}
}
});
defaults().pad(3, 0, 3, 0);
defaults().left();
add(username_field).width(200).row();
add(password_field).width(200).row();
add(userid_field).width(200).row();
add(register_button).colspan(2).right();
//debug();
}
示例13: LoginPanel
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public LoginPanel() {
final TextField username_field = new TextField("", Resources._skin);
// FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/SuperRound.ttf"));
// username_field.getStyle().font = generator.generateFont(12);
username_field.setMaxLength(Settings._max_reister_username_length);
username_field.setMessageText("username ");
final TextField password_field = new TextField( "", Resources._skin);
password_field.setPasswordMode(true);
password_field.setPasswordCharacter('*');
password_field.setMessageText("password ");
password_field.setMaxLength(30);
TextButton login_button = new TextButton("Login", Resources._skin);
login_button.addListener(new ClickListener(){
LoginInfo__ li = new LoginInfo__();
float last_try;
@Override
public void clicked(InputEvent event, float x, float y) {
if ( current_time - last_try > 1 ) {
last_try = current_time;
if ( !Resources._nclient.isConnected()){
Resources._messbar.setText("Error: no connection");
return;
}
String raw_username = username_field.getText();
String raw_password = password_field.getText();
if ( raw_username.length() < Settings._min_reister_username_length ) {
Resources._messbar.setText("Error: username is too short, needs at least "+Settings._min_reister_username_length+" characters");
return;
}
if ( raw_password.length() < Settings._min_reister_password_length ) {
Resources._messbar.setText("Error: password is too short, needs at least "+Settings._min_reister_password_length+" characters");
return;
}
li.username = raw_username.getBytes();
li.one_time_hashed_password = Resources._hash.sha1(raw_password).getBytes();
Resources._nclient.sendLoginInfo(li);
Resources._messbar.setText("Trying loging in", true);
} else {
Resources._messbar.setText("Please slow down click speed");
}
}
});
defaults().pad(3, 0, 3, 0);
defaults().left();
add(username_field).width(200).row();
add(password_field).width(200).row();
add(login_button).colspan(2).right();
//debug();
}
示例14: MainToolbar
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public MainToolbar(Controller controller) {
super(true);
this.controller = controller;
I18N i18N = controller.getApplicationAssets().getI18N();
Skin skin = controller.getApplicationAssets().getSkin();
IconButton eAdventureButton = new IconButton("logomenu64x64",
IMAGE_PADDING, skin);
eAdventureButton.addListener(new ActionOnClickListener(controller,
ShowContextMenu.class, eAdventureButton, buildFileMenu(skin,
i18N)));
add(eAdventureButton).expand(true, true);
LinearLayout controlsTop = new LinearLayout(true);
controlsTop.add(createIcon("back24x24", skin,
i18N.m("maintoolbar.back.tooltip"), Back.class));
controlsTop.add(createIcon("forward24x24", skin,
i18N.m("maintoolbar.next.tooltip"), Next.class));
controlsTop.add(createIcon("help", skin,
i18N.m("maintoolbar.next.tooltip"), OpenBrowser.class,
i18N.m("url.mainhelp")));
TextField searchTextField = new TextField("", skin);
searchTextField.setMessageText(i18N.m("general.search"));
controlsTop.add(searchTextField).margin(5, 0, 0, 0).expandX();
LinearLayout controlsBottom = new LinearLayout(true);
controlsBottom.add(createIcon("save24x24", skin,
i18N.m("maintoolbar.save.tooltip"), Save.class));
controlsBottom.add(new Separator(false, skin));
controlsBottom.add(createIcon("cut24x24", skin,
i18N.m("maintoolbar.cut.tooltip"), Cut.class));
controlsBottom.add(createIcon("copy24x24", skin,
i18N.m("maintoolbar.copy.tooltip"), Copy.class));
controlsBottom.add(createIcon("paste24x24", skin,
i18N.m("maintoolbar.paste.tooltip"), Paste.class));
controlsBottom.add(new Separator(false, skin));
controlsBottom.add(createIcon("undo24x24", skin,
i18N.m("maintoolbar.undo.tooltip"), Undo.class));
controlsBottom.add(createIcon("redo24x24", skin,
i18N.m("maintoolbar.redo.tooltip"), Redo.class));
LinearLayout container = new LinearLayout(false).pad(5)
.defaultWidgetsMargin(0);
container.add(controlsTop).left();
container.add(controlsBottom).left();
add(container).centerY();
}