Discussions
Categories
- 385.5K All Categories
- 4.9K Data
- 2.5K Big Data Appliance
- 2.4K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
re: username and password

843807
Member Posts: 46,582
Used code tags this time. Ya so i was wondering about how to input a username and make it go together with a password.
my frame looks like
Username: ____
Password:______
so i have labels and text fields just need to know how to incorporate them.
I tried the same concept as the password by creating a boolean and setting the correct name but in the actionperformed when i .getText from user input it gives me an error. For the password .getPassword(im using a JPasswordField) it works. Any Ideas
Edited by: babojee on Jun 9, 2010 8:30 PM
Edited by: babojee on Jun 9, 2010 8:35 PM
my frame looks like
Username: ____
Password:______
so i have labels and text fields just need to know how to incorporate them.
I tried the same concept as the password by creating a boolean and setting the correct name but in the actionperformed when i .getText from user input it gives me an error. For the password .getPassword(im using a JPasswordField) it works. Any Ideas
public void actionPerformed( ActionEvent evt) { { String cmd = evt.getActionCommand(); String text = evt.getActionCommand(); if(name.equals(text)) { //here is the error(menutextname is the JTextField) char[] input = menutextname.getText(); } if (password.equals(cmd)) { //Process the password. char[] input = menupasswordtext.getPassword(); if (isPasswordCorrect(input)) { options(); menuframe.setVisible(false); } else { JOptionPane.showMessageDialog(menuframe, "Invalid password. Try again.", "Error Message", JOptionPane.ERROR_MESSAGE); } } } if(evt.getActionCommand().equals("New BS"))//if the action equals 'new game' { BS(); optionframe.setVisible(false); } } private static boolean isNameCorrect(char[] input) { boolean isCorrect= true; char[] correctname = {'b','o','b'}; if (input.length!=correctname.length) { isCorrect=false; } else { isCorrect = Arrays.equals (input, correctname) ; } Arrays.fill(correctname,'0'); return isCorrect; } private static boolean isPasswordCorrect(char[] input) { boolean isCorrect = true; char[] correctPassword = { 'p', 'a', 's', 's', 'w', 'o', 'r','d' }; if (input.length != correctPassword.length) { isCorrect = false; } else { isCorrect = Arrays.equals (input, correctPassword); } //Zero out the password. Arrays.fill(correctPassword,'0'); return isCorrect; } }Edited by: babojee on Jun 9, 2010 7:42 PM
Edited by: babojee on Jun 9, 2010 8:30 PM
Edited by: babojee on Jun 9, 2010 8:35 PM
Comments
-
...in the actionperformed when i .getText from user input it gives me an errorWhat does this mean? Error codes would be nice to have and a complete description would also be very helpful.
-
this line:
char[] input = menutextname.getText();
gives me and error.
basically what im trying to do is create a username and password
if u have any other way of doing the username and password id like to hear it
Edited by: babojee on Jun 10, 2010 3:51 AM -
char[] input = menutextname.getText();Just to finish out your idea...
char[] input = menutextname.getText().toCharArray();
Do you read the API? getText returns String you are asking for an array of chars, if you look in the String API, guess what: it shows toCharArray(). -
thank you, sorry for the trouble
-
No trouble, it's just intersting seeing how many people don't read the free documentation available.
-
srry i never knew about it and im in school and my teacher is like here's a major project, oh and btw u have to learn GUI by yourself and create a program for a client. Useless teachers these days.
one more thing about the username and password
say it the user wants to change it
so i have
old password:
new password:
save(button)
so i was thinking about it as getting the user input just the same as before when the user logins in and getting the users input for new password and then storing/saving into in the char passwordCorrect ( 's'). but the problem with me is i understand it but when i translate it into code it just comes out ................blah.
Edited by: babojee on Jun 11, 2010 12:53 AM -
babojee wrote:Certainly your teachers didn't teach you that every sentence starts with a capital letter, or how to spell words like "sorry" "I'm" "you" or that the first person singular is written with a capital I.
srry i never knew about it and im in school and my teacher is like here's a major project, oh and btw u have to learn GUI by yourself and create a program for a client. Useless teachers these days.
It's not your fault, your teachers are to be blamed... or not?
db -
lol nah he taught nothing at all.
also i know how to spell its just when i type on a computer i use abbreviations.
If I do formal typing I will type properly. -
babojee wrote:Be warned that you are on the express train to 'being ignored for your laziness' if you do not take the time to type properly. If you cannot expend the effort to type properly, why should we expend the effort to wade through such dross?
lol nah he taught nothing at all.
also i know how to spell its just when i type on a computer i use abbreviations.
If I do formal typing I will type properly. -
OK, I'm sorry about that then I just assumed that everyone knows that people type with abbreviations on the internet. It isn't laziness, it is just the way of typing on the internet. If you want me to type properly to you I will then. Now back to my question you guys got any ideas?
This discussion has been closed.