jQuery in Action, 2nd edition*
The moose likes I/O and Streams and the fly likes HELP!!!! verifying userID & Password from Applette Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "HELP!!!! verifying userID & Password from Applette" Watch "HELP!!!! verifying userID & Password from Applette" New topic
Author

HELP!!!! verifying userID & Password from Applette

ione walker
Ranch Hand

Joined: Apr 19, 2001
Posts: 31
I have been given an assinment by a Java teacher
to create a banking application where the first
screen will be the welcome to the program,
User Input of UserID & Password.
& an Submit & Cancel Button.
Once the Submit button is pressed the program
meeds to pull the UserID & Paswd from the
screen & compare it to information comtained
in a file.
If Ok go on to the next screen & iff not
refresh the screen & try again.
So far I have an ugly BUT working applet.
How the heck do I take the userid/pswd
& compair it to a file?

HELP!!!
=======
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.BoxLayout;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.beans.*; //Property change stuff
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*; //for layout managers
import java.awt.event.*; //for action and window events
import java.net.URL;
import java.io.IOException;
public class BankingDemo extends JApplet //implements ActionListener
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout( 6, 1 ));
//define the text labels
JLabel welcomelabel1 = new JLabel( "Welcome to Banking Application" );
welcomelabel1.setFont(new Font("Helvetica", Font.BOLD, 20));
JLabel welcomelabel2 = new JLabel( "Please Enter UserID (ione) & Password (ione)" );
JTextField mytf1 = new JTextField( "Enter your used ID here (ione)" );
JPasswordField mytf2 = new JPasswordField( "Write you Password here" );
JButton buttonSubmit = new JButton( " Submit " );
JButton buttonCancel = new JButton( " Cancel " );
contentPane.add(welcomelabel1);// display Welcome Label
contentPane.add(welcomelabel2);// display Welcome Label
contentPane.add(mytf1);// display userID field
contentPane.add(mytf2);// display passowrd field pane
contentPane.add(buttonSubmit);// display Submit button
contentPane.add(buttonCancel);// display Cancel button
}
}

=======================<BR>Ione Walker<BR>walkeri@usa.net<BR>========================
Ryan Langley
Ranch Hand

Joined: May 10, 2001
Posts: 46
Hello,
What you need to do is:
1) Have the button listen for an action on it. (i.e. addActionListener(new ActionHandler(){void actionPerformed(ActionEvent ae){...}}))
2) Have the actionPerformed code getText() from the username and password fields.
3) Wrap file with RandomAccessFile with read privileges.
4) Compare username with username listed on first line of file, if they don't match read the next line for username, etc.
5) Once you find a username match, check t see if passwords match.
6) if they do, a valid username and password were entered, so the code can continue. Otherwise, refresh the screen.
Hope this helps!

------------------
Cheers,
RL


Cheers,<P>RL
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
hi,
why not storing the usernames and passworts in a property file ?
then the username would be the key, the passort the value.
properties are somewhat like Hashtables. if your user enters a name/password, then you first read the user name, check if this username is contained in the properties. if not: go back and try again. if yes: compare it to the value mapped to the username and if they are the same: ok, if not: try again.
the class you might want look at is:
java.util.Properties
a propertie file si just a file with following format:
someStringWhichIsTheKey=SomeStrngWhichIsTheValue
myUsername=myPassword
karlKoch=iWontTellYou
....
for the rest you can go a described in the post above
karl
 
jQuery in Action, 2nd edition
 
subject: HELP!!!! verifying userID & Password from Applette
 
Similar Threads
i keep on seeing the console window and not the applet
HELP!!!! verifying userID & Password from Applette
Applet Login via database
Problem with default Submit
NX: URLy Bird 1.3.1 Suncertify.properties