Java Code Examples for java.awt.TextField#setEchoChar()

The following examples show how to use java.awt.TextField#setEchoChar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginRequester.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public LoginRequester(Frame parent, String title, String user_label, String password_label, 
	String posText_, String negText) {
  
  super(parent, title, true);
  setLayout(new GridBagLayout());
  posText = posText_;
  
  add(new Label(user_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL));
  u_text = new TextField(30);
  try{u_text.setText(System.getProperty("user.name",""));}
  catch(Exception e) {}
  add(u_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL));
  
  add(new Label(password_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL));
  p_text = new TextField(30);
  p_text.setEchoChar('*');
  add(p_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL));
  
  Button pos = new Button(posText);
  add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL));
  pos.addActionListener(this);
  
  Button neg = new Button(negText);
  add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL));
  neg.addActionListener(this);
  
  pack();
}
 
Example 2
Source File: LoginGUI.java    From KTU-Java with MIT License 4 votes vote down vote up
public LoginGUI(){
	// set title
	super("EventHandling basics");
	txtF1 = new TextField();
	passF = new TextField();
	label1 = new Label();
	label2 = new Label();
	panelLogin = new Panel();
	buttonExit = new Button("close");
	buttonLogin = new Button("login");

	// explictely setting layout. default is Flow itself
	setLayout(new FlowLayout());


	// create a label for username
	label1.setAlignment(Label.CENTER);
	label1.setText("Username");
	add(label1); // add the label to the Frame

	// set initial width of the the TextFields
	txtF1.setColumns(20);
	passF.setColumns(20);

	// changing echoing of characters typed in password field into *
	passF.setEchoChar('*');

	add(txtF1);

	// create a label for password
	label2.setAlignment(Label.CENTER);
	label2.setText("Password");
	add(label2);

	add(passF);

	// create an exit button
	add(buttonExit);

	// login button
	panelLogin.add(buttonLogin);
	add(panelLogin);

	// create an listener object.
	theHandler handler = new theHandler();

	// add action listeners for both the buttons
	buttonExit.addActionListener(handler);
	buttonLogin.addActionListener(handler);
}