Java Swing/GUI Tutorial: Create a Password Field- Password Protecting Program

preview_player
Показать описание
This tutorial will show you how to create a Password field in Java.

A password field can be useful if you only want certain users gaining access to some parts of your program. If you hide the source code or store the password in a different file, then the user cannot see the password by looking at your source code.
Рекомендации по теме
Комментарии
Автор

Very helpful! For future videos, don't have the mic down your throat XD

shadoninja
Автор

There's one line I don't understand, what does the part in parenthesis mean? "JPasswordField input = (JPasswordField) e.getSource();"

Knightmetal
Автор

did you add the actionlistener to the password field?

greywolf
Автор

how do we apply this to things though? can you make another video showing how to do that?

BunkerPainter
Автор

@MrJavaHelp
I've recently used this code however it still allowed access to the code even though they got the password wrong.

SuperZzz
Автор

For checking password I used
String p = passy.toString();
The passwords are not matching though I typed "pass"

However if I type
String p = new String(passy);
Passwords are matching if I type "pass".
Why is that so?

sparkignited
Автор

My conditions don't "if" and "else" statements, when I input password and press ENTER nothing happens!
:(

Dizmin
Автор

@Irvvn I had to sign in to comment on this im in school tryna sneak on youtube and I read this. omg funny. looool.

KhadijahCelestine
Автор

I type in else and it comes up with an error saying:Syntax error on token "else", delete this token

Please tell me how to fix it.

jkurtzman
Автор

Don't set your frame as visible until you have fully initialized it, otherwise you see it jump around a little, there's that small time frame where its not sized right, then it doesn't have anything on it, it's just kinda ugly, better to set it at the end

lemuralex
Автор

Plus i did the frame.validate(); thing. Still nothing

WhoLetTheGuyOut
Автор

When i press enter, Nothing happens. I even set it up so when i press enter it sends a message into the consle, And no message was shown when i pressed enter. Please help.

WhoLetTheGuyOut
Автор

i just started my college java class, and man, for some of the simple prgrams there are alot of lines of code. id hate to see how much is in an advanced program

Ginissi
Автор

it doesn't show the insert space, it only shows the enter password, what did i miss?

Taumich
Автор

you could always just add in

else { //this is for the wrong statement
(JOptionPane.showMessageDialog(null, "Incorrect");
pass.setText(""); //this fills the area as an empty string.
}
I have not used it but it should work.

TheStrifeZero
Автор

Mr . Please Can I Know How To Clear Password If It Was Incorrect

harygonz
Автор

pass.setEchoChar('*'); u have t kepp * in single Quotes thy arent visible here bro

saikumar
Автор

Why the hell are you using that getPassword method and then you convert value to String? You could simply call getString method, since you already made your application unsafe by using this method. You can't use Strings when it comes to JPasswordField!

OverG
Автор

When I press enter nothing happens
Can anyone help?

GeccosGaming
Автор

@Irvvn
I hope you actually did that, I'm thinking of doing the same!

ForeverChillMan