View Single Post
Join Date: Nov 2007
Posts: 2
Reputation: adigha is an unknown quantity at this point 
Solved Threads: 0
adigha adigha is offline Offline
Newbie Poster

help with login applet.

 
0
  #1
Dec 3rd, 2008
hello, i need to create an applet for a "company", in which you log in, and according to your possition(ex: worker, manager) you can see and change different objects such as sallery and the abililty to fire people. im completely stuck on the login part, i have the gui set up but i can't figure out how to get myself to login. this is what i have thus far.


  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.sql.*;
  5. import java.io.*;
  6.  
  7. public class driver extends JApplet
  8. {
  9. private ButtonListener listener;
  10. private JButton btnLogin;
  11. private JTextField txtUser;
  12. private JPasswordField txtPass;
  13. private JLabel lblAccepted;
  14. public String User, Pass;
  15.  
  16.  
  17.  
  18. public void init()
  19. {
  20. Container cp = getContentPane();
  21. cp.setLayout(new FlowLayout());
  22. listener = new ButtonListener();
  23. txtUser = new JTextField("Username");
  24. txtPass = new JPasswordField("Password");
  25. btnLogin = new JButton("Login");
  26. btnLogin.addActionListener(listener);
  27. lblAccepted = new JLabel();
  28. txtUser.setColumns(10);
  29. txtPass.setColumns(10);
  30. txtPass.setEchoChar('*');
  31.  
  32. cp.add(txtUser);
  33. cp.add(txtPass);
  34. cp.add(btnLogin);
  35. cp.add(lblAccepted);
  36. }
  37.  
  38.  
  39.  
  40. public class ButtonListener implements ActionListener
  41. {
  42. public void actionPerformed(ActionEvent event)
  43. {
  44. Object source = event.getSource();
  45.  
  46.  
  47. if (source==btnLogin)
  48. {
  49. User = new String(txtUser.getText());
  50. Pass = new String(txtPass.getPassword());
  51.  
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58.  
  59. }
  60.  
  61. }
  62.  
  63. }


any help would be much appreciated.
Reply With Quote