Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Donna Thompson   on Dec 24 In Java Category.

  
Question Answered By: Jonathan Harrison   on Dec 24

Here is a small sample program I made for you, it
shows how to choose whatever character you want for
you password.

import javax.swing.*;


public class Form extends JFrame
{

JTextField userName = new JTextField(15);
JPasswordField password  = new JPasswordField(15);

JTextArea comments = new JTextArea(4, 15);


public Form()
{

super("Feedback Form");
setSize(260,160);
setDefaultCloseOperation(EXIT_ON_CLOSE);

JPanel pane = new JPanel();

JLabel userNameLabel = new JLabel("Username: ",
SwingConstants.LEFT);
JLabel passwordLabel = new JLabel("Password: ",
SwingConstants.LEFT);
JLabel commentsLabel = new JLabel("Comments: ",
SwingConstants.LEFT);

password.setEchoChar('@');

comments.setLineWrap(true);
comments.setWrapStyleWord(true);

pane.add(userNameLabel);
pane.add(userName);
pane.add(passwordLabel);
pane.add(password);
pane.add(commentsLabel);
pane.add(comments);

setContentPane(pane);

//pack();

setVisible(true);
}


public static void main(String[] args)
{
Form frm = new Form();
}
}

Share: 

 
 
Didn't find what you were looking for? Find more on how to hide password on console Or get search suggestion and latest updates.


Tagged: