codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  does anyone know how I can create a password for my java netbeans application?  sethmtut at 16:35 on Monday, August 20, 2007
 

Hi, Iv made a small program but I would like to password it to gain extra marks. I'd like a message to show on opening the application inviting them to log in using their user details. Ideally a correct password should be required but it dosent really matter. At the moment I have come up with this code, but im not sure how to get it to work when the application is openend. If anyone can edit or tell me how to get it to pop up a password required message I'd be really greatful.



public class TestApp implements ActionListener {
JTextField textField;

public void actionPerformed(ActionEvent e) {
JButton button = (JButton)e.getSource();
String ac = button.getActionCommand();
if(ac.equals("log in"))
System.out.println("logging in..." + textField.getText());
// Verify name and password. If okay, you can
// show the next panel in a CardLayout. This
// next panel can have your display animation
// and controls on it.
}

private JPanel getContent() {
textField = new JTextField(12);
JButton logIn = new JButton("log in");
logIn.setActionCommand("log in");
logIn.addActionListener(this);
JPanel p = new JPanel();
p.add(new JLabel("name:"));
p.add(textField);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel("sign in", JLabel.CENTER), "North");
panel.add(p, "Center");
p = new JPanel();
p.add(logIn);
panel.add(p, "South");
return panel;


}
}

  Re: does anyone know how I can create a password for my java netbeans application?  mmarab at 14:03 on Wednesday, August 22, 2007
 

Have a look at this link:

http://java.sun.com/docs/books/tutorial/uiswing/components/passwordfield.html








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo
•  Cookies and Threads C++
•  right justify a background in a table?
•  Help with Loop (C++/MFC)
•  Help with Loop (C++/MFC)


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007