Showing posts with label field. Show all posts
Showing posts with label field. Show all posts

Create password field using JPasswordField

Source code below will show you, how to create password field in java using JPasswordField class.

*********************************************************************
COMPLETE SOURCE CODE FOR : CreatePasswordFieldUsingJPasswordField.java
*********************************************************************


import javax.swing.JFrame;
import javax.swing.JPasswordField;

import java.awt.FlowLayout;

public class CreatePasswordFieldUsingJPasswordField
{
public static void main(String[]args)
{
//Create password field with number of columns equal 10
//Number of columns is use to calculate preferred size
//You can change it for what value that you want but make sure it positive integer
JPasswordField passwordField=new JPasswordField(10);

//Create JFrame that will be use to place created JPasswordField
JFrame frame=new JFrame("Create password field");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add password field into JFrame
frame.add(passwordField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size to :
//WIDTH : 400 pixels
//HEIGHT : 100 pixels
frame.setSize(400,100);

//Make JFrame visible. So we can see it.
frame.setVisible(true);
}
}


*********************************************************************
JUST COMPILE AND EXECUTE IT
*********************************************************************

Create password field in java

In java, you can create a password field using JPasswordField class.

RELAXING NATURE VIDEO