Results 1 to 2 of 2
  1. #1
    marilux is offline Member
    Join Date
    Jul 2011
    Rep Power

    Exclamation Convert a JTextField to a JPasswordField

    Hi, I need to add, to an already created JTextField the echoChar of * like it is a JPasswordField, is any way to change the renderer of a JTextField?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    I do not see why you can't use a JPasswordField, but that aside one way would be to extend one of the classes which implement the Document interface and override a few of its methods (remove, insertString, getText(), etc...). You can keep a StringBuilder variable which holds the true password value and is modified by the override methods, but in insertString call the super method to insert *'s. Why do all this when its done for you in a JPasswordField though.

Similar Threads

  1. JPasswordField question..
    By Chick786 in forum New To Java
    Replies: 1
    Last Post: 04-11-2010, 09:01 PM
  2. Replies: 5
    Last Post: 03-14-2010, 11:21 PM
  3. Any workarounds for JPasswordField in JDialog bug?
    By dtmansy in forum Advanced Java
    Replies: 5
    Last Post: 02-24-2010, 12:56 AM
  4. Convert Input from JTextField to int?
    By jls7168 in forum New To Java
    Replies: 7
    Last Post: 02-20-2009, 03:29 AM
  5. Ask about JPasswordfield
    By yonghan in forum AWT / Swing
    Replies: 7
    Last Post: 09-14-2008, 12:54 PM

Tags for this Thread

Posting Permissions

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