本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.TextField.setMaxLength方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setMaxLength方法的具体用法?Java TextField.setMaxLength怎么用?Java TextField.setMaxLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.TextField
的用法示例。
在下文中一共展示了TextField.setMaxLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTextfield
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public TextField createTextfield(final String text) {
TextField _xblockexpression = null;
{
Skin _skin = this.manager.getSkin();
final TextField textfield = new TextField(text, _skin);
textfield.setMaxLength(16);
textfield.selectAll();
_xblockexpression = textfield;
}
return _xblockexpression;
}
示例2: 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;
}
示例3: 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();
}
示例4: NewSave
import com.badlogic.gdx.scenes.scene2d.ui.TextField; //导入方法依赖的package包/类
public NewSave(OdysseeDesMaths game) {
this.game = game;
viewport = new StretchViewport(WIDTH, HEIGHT);
stage = new Stage(viewport);
Gdx.input.setInputProcessor(stage);
table = new Table();
table.setFillParent(true);
stage.addActor(table);
skin = new Skin();
skin.addRegions(Assets.getManager().get(Assets.UI_MAIN, TextureAtlas.class));
skin.addRegions(Assets.getManager().get(Assets.UI_ORANGE, TextureAtlas.class));
skin.add("background", Assets.getManager().get(Assets.MAIN_MENU_BACKGROUND, Texture.class));
skin.add("title", new LabelStyle(TITLE, null));
skin.add("text", new LabelStyle(TEXT, null));
TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.font = TEXT;
textButtonStyle.up = skin.getDrawable("button");
textButtonStyle.down = skin.getDrawable("button_pressed");
skin.add("textButton", textButtonStyle);
TextFieldStyle textFieldStyle = new TextFieldStyle();
textFieldStyle.font = TEXT;
textFieldStyle.fontColor = Color.BLACK;
textFieldStyle.background = skin.getDrawable("field");
textFieldStyle.focusedBackground = skin.getDrawable("field_focused");
skin.add("textField", textFieldStyle);
ButtonStyle returnButtonStyle = new ButtonStyle();
returnButtonStyle.up = skin.getDrawable("return");
skin.add("returnButton", returnButtonStyle);
gameTitle = new Label("L'Odyssée des Maths", skin, "title");
saveNameLabel = new Label("Nom:", skin, "text");
saveNameField = new TextField("", skin, "textField");
saveNameField.setMaxLength(7);
submit = new TextButton("C'est parti !", skin, "textButton");
audioButtons = new AudioButtons();
returnButton = new Button(skin, "returnButton");
table.setBackground(skin.getDrawable("background"));
table.padTop(HEIGHT / 13);
table.add(gameTitle).top().colspan(2).padBottom(HEIGHT / 9).expandX();
table.row().padBottom(HEIGHT / 10);
table.add(saveNameLabel).right().padRight(10);
table.add(saveNameField).size(200, 48).left();
table.row();
table.add(submit).size(350, 64).top().colspan(2).expandY();
table.row();
table.add(audioButtons).left();
table.add(returnButton).right();
NewSaveListener listener = new NewSaveListener();
submit.addListener(listener);
returnButton.addListener(listener);
noNameSubmitAction = new ColorAction();
noNameSubmitAction.setEndColor(Color.WHITE);
noNameSubmitAction.setDuration(0.5f);
}
示例5: 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.setMaxLength(parser.parseInt(rawAttributeData, actor));
}
示例6: 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();
}
示例7: 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();
}