943,892 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 747
  • Java RSS
Dec 3rd, 2008
0

help with login applet.

Expand Post »
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.


java Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adigha is offline Offline
2 posts
since Nov 2007
Dec 3rd, 2008
0

Re: help with login applet.

Can you tell me the architecture of the system ??

And how do you plan to validate users ??? Do you have a central database server or is it small school / college assignment where your database will be MS Access / etc and it will reside on the machine where the applet is running ??
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Dec 3rd, 2008
0

Re: help with login applet.

Are you planning to connect the applet to a database on the server ?
Provide more details so that we can help you.
Reputation Points: 485
Solved Threads: 89
Posting Shark
verruckt24 is offline Offline
944 posts
since Nov 2008
Dec 3rd, 2008
0

Re: help with login applet.

I agree with stephen84s, you need some sort of overall view of how the different parts of your system pull together.

Generally if you have an applet, it would probably have to communicate with a server that would fulfil requests such as user authentication. It would communicate with the server by means of a socket and the server would understand the communication because you would have programmed the server. I'm not sure if you already know this but I just thought I'd make a suggestion.

If what I explained is what you were uncertain about then let us know and we'll explain it further. Oh there are other ways to do this but what I described is probably the easiest and most used (client-server architecture). It's especially useful when you have multiple applets loaded from various sites. Alternatively you could create a dynamic web project... probably more flexible than an applet.
Reputation Points: 56
Solved Threads: 11
Junior Poster
PoovenM is offline Offline
147 posts
since Aug 2006
Dec 4th, 2008
0

Re: help with login applet.

im going to have the users/passwords stored in the program, no securty or anything is needed, its a small school project. So that if the username textfiend and password fields have the correct information it shows you a new page in which your work status decides what you see and not.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adigha is offline Offline
2 posts
since Nov 2007
Dec 4th, 2008
0

Re: help with login applet.

Ah well then doesn't that answer your question about logging in? Comparing input with predefined values in your program seems perfectly acceptable for your application. I guess what you want to know is how to change from the log in screen to the content/menu screen?

What you could do is have multiple panels on your applet and make them visible in correspondence to who logs in. In that way, when a worker enters his details correctly, the log in screen is made invisible and the worker screen is made visible. Not the most elaborate solution but rather simple don't you think? Perhaps you should disable the panel when you make it invisible... and enable it when made visible.

Hope this makes sense, otherwise give us a shout.
Reputation Points: 56
Solved Threads: 11
Junior Poster
PoovenM is offline Offline
147 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Array String
Next Thread in Java Forum Timeline: Recursion Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC