0% found this document useful (0 votes)
81 views1 page

How To Hide A Password and Make A Box

This document shows how to create a password input box in Java. It creates a horizontal box to hold the label and password field. It adds a "Password" label and a password field of length 24 to the box. It then displays the box in a confirmation dialog and checks if the entered password matches a predefined password.

Uploaded by

bing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views1 page

How To Hide A Password and Make A Box

This document shows how to create a password input box in Java. It creates a horizontal box to hold the label and password field. It adds a "Password" label and a password field of length 24 to the box. It then displays the box in a confirmation dialog and checks if the entered password matches a predefined password.

Uploaded by

bing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

HOW TO HIDE A PASSWORD AND MAKE A BOX

Box box = Box.createHorizontalBox();


JLabel jl = new JLabel("Password: ");
box.add(jl);
JPasswordField jpf = new JPasswordField(24);
box.add(jpf);
int button = JOptionPane.showConfirmDialog(null, box, "Enter your password",
JOptionPane.OK_CANCEL_OPTION);
if (button == JOptionPane.OK_OPTION) {
char[] input = jpf.getPassword();
if(input.equals(password)) {
...
}
}

You might also like