Results 1 to 3 of 3
  1. #1
    garnachito is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default JPasswordField show a default text ?

    Hi all

    I want to know how to show a default message in a JPasswordField box something like "At least 8 chars", let me show you.

    If it do this:

    Java Code:
    passBox=new JPasswordField("At least 8 chars");
    It shows this " ************* " instead of the text.

    So I want this to show me the default message but also and very important I want this to hide the password when the users start to type it.
    (I've already added a MouseListener so when the users click on the password field, they don't need to delete the default text).

    Thanks in advance

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: JPasswordField show a default text ?

    See the API for JPasswordField, the setEchoChar allows you to set a value (0) that indicates you wish to see the text...change this '*' when the user clicks the component.

  3. #3
    garnachito is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: JPasswordField show a default text ?

    Quote Originally Posted by doWhile View Post
    See the API for JPasswordField, the setEchoChar allows you to set a value (0) that indicates you wish to see the text...change this '*' when the user clicks the component.
    Thanks a lot! that worked perfectly.

Similar Threads

  1. Java text boxes does not show
    By zAxOanL in forum New To Java
    Replies: 0
    Last Post: 03-25-2012, 04:08 AM
  2. get text and show it and save it
    By pinar.n in forum AWT / Swing
    Replies: 1
    Last Post: 07-03-2011, 07:05 PM
  3. show text file to textArea
    By louboulos in forum New To Java
    Replies: 14
    Last Post: 06-12-2011, 01:16 PM
  4. Show Text with cursor
    By ravjot28 in forum AWT / Swing
    Replies: 3
    Last Post: 01-20-2010, 09:30 PM
  5. Opening Text Files with Default System Editor
    By Pesch in forum Advanced Java
    Replies: 5
    Last Post: 10-08-2008, 06:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •