Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Input username and password in JAVA

Fri Apr 10, 2009 12:37 pm

How to take Username and Password from user in Java
if you can use java netbeans 6 point something.you can do it in design mode.just drag jlabel1 for user name then drag jtextfield ,then drag jpasswordfield for password.and drag a button for action.if you double click in button then created jButton1ActionPerformed. At last you can run this code in JButton1ActionPerformed

Code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//// Action submit button for main form submit//
       
    String user_name
=jTextField1.getText();
        String pasword=jPasswordField1.getText();
    if(user_name==" " || pasword==" ")
{
  JOptionPane.showMessageDialog(null,"Invalid User Name or Password","Error",JOptionPane.ERROR_MESSAGE);
}

if you want file upload as like text file.you can see this code for file chooser 

private JFileChooser fileChooser
;

 try
           
{
            fileChooser = new JFileChooser();
            int result= fileChooser.showOpenDialog(this);                   
            if
(result==JFileChooser.CANCEL_OPTION)
                 {
                   JOptionPane.showMessageDialog(null,"You Cancel it.","Warning",JOptionPane.ERROR_MESSAGE);
                 } 
             else
                 
{
              your work
                
}
catch(
FileNotFoundException exception)
           {
           } 




Post a reply
  Related Posts  to : Input username and password in JAVA
 Mile200: Removing Username, Password & Login from Header     -  
 AJAX Login Code getting username and password dynamically .     -  
 Password Security Manager Access File Java     -  
 validate username     -  
 generate password using php     -  
 how to encrypt password in jsp     -  
 php Password protect a page     -  
 Protect page using password in PHP     -  
 simple password Strength checker     -  
 input suggestion using Javascript     -  

Topic Tags

Java Swing