RSS Forums RSS

help with login applet.

Please support our Java advertiser: Programming Forums
Reply
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.

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,143
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 121
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: help with login applet.

  #2  
Dec 3rd, 2008
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 ??
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote  
Posts: 812
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 72
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: help with login applet.

  #3  
Dec 3rd, 2008
Are you planning to connect the applet to a database on the server ?
Provide more details so that we can help you.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote  
Posts: 137
Reputation: PoovenM is on a distinguished road 
Solved Threads: 11
PoovenM PoovenM is offline Offline
Junior Poster

Re: help with login applet.

  #4  
Dec 3rd, 2008
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.
Reply With Quote  
Posts: 2
Reputation: adigha is an unknown quantity at this point 
Solved Threads: 0
adigha adigha is offline Offline
Newbie Poster

Re: help with login applet.

  #5  
Dec 4th, 2008
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.
Reply With Quote  
Posts: 137
Reputation: PoovenM is on a distinguished road 
Solved Threads: 11
PoovenM PoovenM is offline Offline
Junior Poster

Re: help with login applet.

  #6  
Dec 4th, 2008
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Java Forum
Views: 405 | Replies: 5 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:41 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC