• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

HELP!!!! verifying userID & Password from Applette

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
}
}
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic