List of usage examples for com.badlogic.gdx.scenes.scene2d.ui TextField setPasswordCharacter
public void setPasswordCharacter(char passwordCharacter)
From source file:ateamproject.kezuino.com.github.render.screens.LoginScreen.java
public LoginScreen(Game game) { super(game);// w w w .j a v a 2 s. c o m TextField txtUsername = new TextField("pactales1@gmail.com", skin); TextField txtPassword = new TextField("pactales!", skin); txtPassword.setPasswordCharacter('*'); txtPassword.setPasswordMode(true); TextButton btnLogin = new TextButton("Inloggen", skin); btnLogin.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { btnLogin.setTouchable(Touchable.disabled); btnLogin.setText("Laden"); Thread loginThread = new Thread(() -> { PacketLoginAuthenticate packet = new PacketLoginAuthenticate(txtUsername.getText(), txtPassword.getText(), null); Client.getInstance().send(packet); Gdx.app.postRunnable(() -> { // Login was successful.. if (Client.getInstance().getId() != null) { PacketLoginUserExists packetUserExists = new PacketLoginUserExists( txtUsername.getText(), null); Client.getInstance().send(packetUserExists); // Handle user doesn't exist. if (!packetUserExists.getResult()) { Dialog d = new Dialog("Geen gebruiker gevonden", skin); d.add("Gebruikersnaam:"); TextField f = new TextField("", skin); d.add(f); bExit = new TextButton("Oke", skin); bExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!f.getText().isEmpty()) { PacketLoginCreateNewUser packet1; packet1 = new PacketLoginCreateNewUser(f.getText(), txtUsername.getText()); Client.getInstance().send(packet1); if (!packet1.getResult()) { new Dialog("Error", skin) { { text("De naam bestaat al."); button("Oke"); } }.show(stage); } else { d.hide(); Client.getInstance().setUsername(f.getText()); game.setScreen(new MainScreen(game)); } } } }); d.add(bExit); d.show(stage); } else { game.setScreen(new MainScreen(game)); } } else { new Dialog("Error", skin) { { text(packet.getResult().getMessage()); button("Oke"); } }.show(stage); } btnLogin.setText("Inloggen"); btnLogin.setTouchable(Touchable.enabled);//enable button touch }); }); loginThread.start(); } }); txtUsername.setSize(300, 40); txtPassword.setSize(300, 40); txtPassword.setPasswordMode(true); btnLogin.setSize(300, 40); btnLogin.setPosition(stage.getWidth() / 2 - btnLogin.getWidth() / 2, 150); txtUsername.setPosition(stage.getWidth() / 2 - txtUsername.getWidth() / 2, 300); txtPassword.setPosition(stage.getWidth() / 2 - txtPassword.getWidth() / 2, 250); stage.addActor(btnLogin); stage.addActor(txtUsername); stage.addActor(txtPassword); backgroundMusic = Assets.getMusicStream("menu.mp3"); }
From source file:com.digitale.screens.Login.java
License:Open Source License
public Login(String newslines) { //all sounds loaded, now bind them try {// w ww.j a v a2s . co m Renderer.bindMeshes(0); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Button buttonLogin = new TextButton("Log in", skin.getStyle(TextButtonStyle.class), "buttonLogin"); final Button buttonHelp = new TextButton("Quick Help", skin.getStyle(TextButtonStyle.class), "buttonHelp"); final Button buttonNewAccount = new TextButton("New Account", skin.getStyle(TextButtonStyle.class), "buttonNewAccount"); final Button buttonOptions = new TextButton("Options", skin.getStyle(TextButtonStyle.class), "buttonOptions"); final CheckBox checkBox = new CheckBox("Remember account name and password.", skin.getStyle(CheckBoxStyle.class), "checkbox"); final TextField textfieldUserName = new TextField("", "Account Name", skin.getStyle(TextFieldStyle.class), "textfield"); // final List list = new List(listEntries, // skin.getStyle(ListStyle.class), "list"); final Label labelStories = new Label(newslines, skin); labelStories.setWrap(true); final ScrollPane scrollPane2 = new ScrollPane(labelStories, skin.getStyle(ScrollPaneStyle.class), "scroll"); // configures an example of a TextField in password mode. final Label lableNews = new Label("News: ", skin); final TextField passwordTextField = new TextField("", "password", skin); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); textfieldUserName.getOnscreenKeyboard().show(true); Boolean booltemp = prefs.getBoolean("nopoly", false); //is save account checked in prefs if (booltemp) { //if preferences account is too short to have been set to a valid account name checkBox.setChecked(true); String temp = prefs.getString("un", ""); ac = temp; textfieldUserName.setText(ac); temp = prefs.getString("cullingtree", ""); String pw = null; try { pw = new String(mcrypt.decrypt(temp.trim())); pw = pw.replace('~', ' ').trim(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } passwordTextField.setText(pw); } Window window = new Window("Login Screen", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5); //build table window.row().fill().expandX(); window.add(buttonNewAccount).colspan(1).align("Centre"); window.add(buttonOptions).colspan(1).align("center"); window.add(buttonHelp).colspan(1).align("center"); window.add(buttonLogin).colspan(1).align("right"); window.row(); window.add(textfieldUserName).minWidth(100).expandX().fillX().colspan(2); window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2); window.row(); window.add(lableNews).align("left"); window.row(); window.add(scrollPane2).fill().expand().colspan(4); window.row(); window.add(checkBox).colspan(4); window.row(); window.pack(); stage.addActor(window); SoundManager.init(); try { Renderer.bindMeshes(1); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } textfieldUserName.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); buttonLogin.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { try { Renderer.bindMeshes(2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (Stardust3d.DEBUG) System.out.println("login button pressed"); SoundManager.playuiclick(); ac = textfieldUserName.getText().toString(); String pw = passwordTextField.getText().toString(); if (checkpass(pw, pw) && checkuser(ac)) { String passed = Stardust3d.MyDataOp.login(ac, pw); if (Stardust3d.DEBUG) System.out.println("passed " + passed); if (passed.equals("true")) { SoundManager.playconfirm(); stage.addActor(Actors.bottomToast("Login sucessful", 4, skin)); Stardust3d.mloginOK = true; Stardust3d.gameMode = 3; //get players characters Stardust3d.populateCharacterlist(Stardust3d.muser); doneflag = true; isDone(); } else if (passed.equals("NOT_ACTIVE")) { SoundManager.playError(); stage.addActor(Actors.bottomToast( "Login failed, this account is not active, check your Email.", 4, skin)); } else if (passed.equals("false")) { SoundManager.playError(); stage.addActor(Actors.bottomToast( "Login failed, please check your account name and password.", 4, skin)); } } } }); buttonOptions.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("options button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 6; doneflag = true; } }); buttonNewAccount.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("New account button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 14; doneflag = true; } }); buttonHelp.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("help button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 9; doneflag = true; } }); checkBox.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); String encrypted = null; if (Stardust3d.DEBUG) System.out.println("remeber account name pressed"); Stardust3d.mremeberAccountname = checkBox.isChecked(); //if user wants to save login if (Stardust3d.mremeberAccountname) { String pw = passwordTextField.getText().toString(); String acc = textfieldUserName.getText().toString(); //check user has entered account details before saving if (pw.length() > 8 && acc.length() > 8) { /* Encrypt */ try { encrypted = (mcrypt.encrypt(pw)); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname); prefs.putString("un", acc); prefs.putString("cullingtree", encrypted); prefs.flush(); } else { stage.addActor(Actors.bottomToast( "You need to enter your account name and password before trying to save them.", 4, skin)); checkBox.setChecked(false); } } else { stage.addActor(Actors.bottomToast("Saved account details cleared.", 4, skin)); //clear saved account details prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname); prefs.putString("un", ""); prefs.putString("cullingtree", ""); prefs.flush(); } } }); }
From source file:com.digitale.screens.NewAccount.java
License:Open Source License
public NewAccount() { OrthographicCamera camera;//from w w w . j ava 2 s. co m batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Label labelEmail = new Label( "Valid email address (Stardust will send an activation mail to this address).", skin); final Label labelAccountName = new Label("Account Name (must contain at least 8 letters or numbers).", skin); final Label labelPassword1 = new Label( "Password (must be at least 8 letters and include a capital letter and a number).", skin); final Label labelPassword2 = new Label("Repeat Password", skin); final Button buttonCreateAccount = new TextButton("Create Account", skin.getStyle(TextButtonStyle.class), "buttonCreateAccount"); final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel"); final TextField textfieldEmail = new TextField("", "Email address", skin.getStyle(TextFieldStyle.class), "textfield"); final TextField textfieldUserName = new TextField("", "Account Name", skin.getStyle(TextFieldStyle.class), "textfield"); // configure TextField in password mode. final Label lableNews = new Label("News: ", skin); final TextField passwordTextField = new TextField("", "Password", skin); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); //password confirmation box final TextField password2TextField = new TextField("", "Repeat password", skin); password2TextField.setPasswordCharacter('*'); password2TextField.setPasswordMode(true); Window window = new Window("New Account Screen", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5).align("left"); //build table window.row().fill().expandX(); window.add(buttonCancel).colspan(1); window.add(); window.add(buttonCreateAccount).colspan(1); window.row(); window.add(labelEmail).colspan(3); window.row(); window.add(textfieldEmail).minWidth(400).colspan(3); window.row(); window.add(labelAccountName).colspan(3); window.row(); window.add(textfieldUserName).minWidth(400).colspan(3); window.row(); window.add(labelPassword1).minWidth(400).colspan(3); window.row(); window.add(passwordTextField).minWidth(400).colspan(3); window.row(); window.add(labelPassword2).minWidth(400).colspan(3); window.row(); window.add(password2TextField).minWidth(400).colspan(3); window.pack(); stage.addActor(window); textfieldUserName.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); buttonCreateAccount.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { System.out.println("create account button pressed"); SoundManager.playuiclick(); ac = textfieldUserName.getText().toString(); mpw1 = passwordTextField.getText().toString(); mpw2 = password2TextField.getText().toString(); memail = textfieldEmail.getText().toString(); if (checkEmail(memail.toLowerCase())) { if (checkuser(ac)) { if (checkpass(mpw1, mpw2)) { if (checkuserandpassaredifferent(ac, mpw1)) { Stardust3d.MyDataOp.getFreeUser(ac); if (Stardust3d.muserExists.equals("0")) { SoundManager.playconfirm(); if (Stardust3d.DEBUG) System.out.println(LOG_TAG + " " + mpw1); stage.addActor(Actors.bottomToast( "Your account has been created, please check your EMail.", 4, skin)); Stardust3d.MyDataOp.createUser(ac, mpw1, memail); //TODO need pause in here so toast can display Stardust3d.gameMode = 2; doneflag = true; } else { //user name is already in database SoundManager.playError(); stage.addActor(Actors.bottomToast( "Sorry, this account name is used, please try another.", 4, skin)); } } else { //the username and password are the same SoundManager.playError(); stage.addActor(Actors.bottomToast("Your username and password cannot be the same.", 4, skin)); } } else { //password is not good enough SoundManager.playError(); stage.addActor(Actors.bottomToast( "There is a problem with your password, please check it.", 4, skin)); } } else { //username is not good enough SoundManager.playError(); stage.addActor(Actors.bottomToast("There is a problem with your username, please check it.", 4, skin)); } } else { //email is not valid SoundManager.playError(); stage.addActor( Actors.bottomToast("This does not appear to be a valid Email address.", 4, skin)); } } }); buttonCancel.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { System.out.println("new account cancel button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 2; doneflag = true; } }); }
From source file:com.digitale.screens.UIStuff.java
License:Open Source License
public UIStuff(Application app) { batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); texture1 = new Texture(Gdx.files.internal("data/badlogicsmall.jpg")); texture2 = new Texture(Gdx.files.internal("data/badlogic.jpg")); TextureRegion image = new TextureRegion(texture1); TextureRegion image2 = new TextureRegion(texture2); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage);/*from w ww . j av a 2s . c o m*/ // Group.debug = true; final Button button = new TextButton("Single", skin.getStyle(TextButtonStyle.class), "button-sl"); final Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin.getStyle("toggle", TextButtonStyle.class), "button-ml-tgl"); final Button imgButton = new Button(new Image(image), skin.getStyle(ButtonStyle.class)); final Button imgToggleButton = new Button(new Image(image), skin.getStyle("toggle", ButtonStyle.class)); final CheckBox checkBox = new CheckBox("Check me", skin.getStyle(CheckBoxStyle.class), "checkbox"); final Slider slider = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slider"); final TextField textfield = new TextField("", "Click here!", skin.getStyle(TextFieldStyle.class), "textfield"); final SelectBox dropdown = new SelectBox(new String[] { "Android", "Windows", "Linux", "OSX" }, skin.getStyle(SelectBoxStyle.class), "combo"); final Image imageActor = new Image(image2); final FlickScrollPane scrollPane = new FlickScrollPane(imageActor, "flickscroll"); final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list"); final ScrollPane scrollPane2 = new ScrollPane(list, skin.getStyle(ScrollPaneStyle.class), "scroll"); final SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, skin.getStyle("default-horizontal", SplitPaneStyle.class), "split"); final Label fpsLabel = new Label("fps:", skin.getStyle(LabelStyle.class), "label"); // configures an example of a TextField in password mode. final Label passwordLabel = new Label("Textfield in password mode: ", skin); final TextField passwordTextField = new TextField("", "password", skin); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); // window.debug(); Window window = new Window("Dialog", skin.getStyle(WindowStyle.class), "window"); window.x = window.y = 0; window.defaults().spaceBottom(5); window.row().fill().expandX(); window.add(button).fill(0f, 0f); window.add(buttonMulti); window.add(imgButton); window.add(imgToggleButton); window.row(); window.add(checkBox); window.add(slider).minWidth(100).fillX().colspan(3); window.row(); window.add(dropdown); window.add(textfield).minWidth(100).expandX().fillX().colspan(3); window.row(); window.add(splitPane).fill().expand().colspan(4).maxHeight(150); window.row(); window.add(passwordLabel).colspan(2); window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2); window.row(); window.add(fpsLabel).colspan(4); window.pack(); // stage.addActor(new Button("Behind Window", skin)); stage.addActor(window); textfield.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); slider.setValueChangedListener(new ValueChangedListener() { public void changed(Slider slider, float value) { Gdx.app.log("UITest", "slider: " + value); } }); }
From source file:net.mwplay.cocostudio.ui.parser.widget.CCTextField.java
License:Apache License
@Override public Actor parse(CocoStudioUIEditor editor, ObjectData widget) { final TTFLabelStyle labelStyle = editor.createLabelStyle(widget, widget.getPlaceHolderText(), editor.getColor(widget.getCColor(), 0)); TextFieldStyle style = new TextFieldStyle(labelStyle.font, labelStyle.fontColor, null, null, null); TextField textField = new TextField(widget.getLabelText(), style) { @Override//from w ww. j a va 2 s . c om public void setText(String text) { String sumText = text + getMessageText() + defaultText; /*getStyle().font = FontUtil.createFont( labelStyle.getFontFileHandle(), sumText, labelStyle.getFontSize());*/ super.setText(text); } @Override public void setMessageText(String messageText) { String sumText = messageText + getText() + defaultText; /*getStyle().font = FontUtil.createFont( labelStyle.getFontFileHandle(), sumText, labelStyle.getFontSize());*/ super.setMessageText(messageText); } }; textField.setMaxLength(widget.getMaxLengthText()); textField.setMessageText(widget.getPlaceHolderText()); textField.setPasswordMode(widget.isPasswordEnable()); textField.setPasswordCharacter(widget.getPasswordStyleText()); return textField; }