| | |
help with login applet.
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
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.
any help would be much appreciated.
java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; import java.io.*; public class driver extends JApplet { private ButtonListener listener; private JButton btnLogin; private JTextField txtUser; private JPasswordField txtPass; private JLabel lblAccepted; public String User, Pass; public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); listener = new ButtonListener(); txtUser = new JTextField("Username"); txtPass = new JPasswordField("Password"); btnLogin = new JButton("Login"); btnLogin.addActionListener(listener); lblAccepted = new JLabel(); txtUser.setColumns(10); txtPass.setColumns(10); txtPass.setEchoChar('*'); cp.add(txtUser); cp.add(txtPass); cp.add(btnLogin); cp.add(lblAccepted); } public class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (source==btnLogin) { User = new String(txtUser.getText()); Pass = new String(txtPass.getPassword()); } } } }
any help would be much appreciated.
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 ??
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 ?"
"How to ask questions the smart way ?"
•
•
Join Date: Aug 2006
Posts: 137
Reputation:
Solved Threads: 11
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.
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.
•
•
Join Date: Aug 2006
Posts: 137
Reputation:
Solved Threads: 11
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.
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.
![]() |
Similar Threads
- Applet and i/o (Java)
- How to make a user account login by default (Windows NT / 2000 / XP)
- People on Page? (Viruses, Spyware and other Nasties)
- Is my laptop infested? (Viruses, Spyware and other Nasties)
- WinPcap 3.0? (Windows NT / 2000 / XP)
- Help with Hijack Log Please (Viruses, Spyware and other Nasties)
- fastsearch will NOT go away!! please help (Viruses, Spyware and other Nasties)
- Internet Exploer is not opening Stites (Web Browsers)
Other Threads in the Java Forum
- Previous Thread: Array String
- Next Thread: Recursion Problem
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card chat class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting scanner se server service set sms socket software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows






