How to create password field in Swing

0 votes
I want to create a password field to take a login password. I don’t want to the text typed to be visible. I want it to be masked with an asterisk or some other special character. How to do this in Swing?
Aug 27, 2019 in Java by Quill
205 views

1 answer to this question.

0 votes

Swing provides an object called JPasswordField for this requirement. This object creates a text box but masks the typed input.

JFrame f=new JFrame("Login");

JPasswordField pass=new JPasswordField();

f.add(pass);
answered Aug 27, 2019 by Bruce

Related Questions In Java

0 votes
2 answers

How to create a 2-D array in java?

int[][] multi = new int[5][]; multi[0] = new ...READ MORE

answered Jul 16, 2018 in Java by Daisy
• 8,120 points
389 views
0 votes
1 answer

How to create a temporary directory/folder in java?

If you are using JDK 7 use ...READ MORE

answered Aug 28, 2018 in Java by Frankie
• 9,830 points
5,580 views
0 votes
1 answer

How to get text from text box in Swing?

You can add a Button listener here. ...READ MORE

answered Aug 27, 2019 in Java by Jishan
456 views
+1 vote
1 answer

How to create database in MySql using Java?

First, you will have to create connection ...READ MORE

answered Sep 30, 2019 in Java by Shri
2,309 views
0 votes
1 answer

revalidate() vs repaint() in Java Swing

You need to call repaint() and revalidate() both in order ...READ MORE

answered Sep 20, 2018 in Java by code.reaper12
• 3,500 points
7,084 views
0 votes
1 answer

Fetching screen resolution using Java

You can fetch the screen resolution using the Toolkit.getScreenSize() method ...READ MORE

answered Sep 20, 2018 in Java by anto.trigg4
• 3,440 points
3,009 views
0 votes
1 answer

How to change selection listener in JComboBox?

It should respond to ActionListeners, like this: combo.addActionListener (new ...READ MORE

answered Nov 15, 2018 in Java by Frankie
• 9,830 points
489 views
0 votes
1 answer

Describe Heavy Weight Components Mean In Java Programming?

Heavy weight components like Abstract Window Toolkit ...READ MORE

answered Nov 28, 2018 in Java by Frankie
• 9,830 points
742 views
0 votes
1 answer

How to create text labels in Swing, Java?

In the frame, you can use the ...READ MORE

answered Aug 27, 2019 in Java by Jimmy
267 views
0 votes
1 answer

How to create database in MySql using Java?

First, you will have to create connection ...READ MORE

answered Aug 27, 2019 in Java by Juni
230 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP