Join us on Facebook

Please wait..10 Seconds Cancel

11.08.2013

// // 1 comment

Create a student registration form by using different components and displays all the inputs on TextArea.

Student Registration Form
import javax.swing.*; 
import java.awt.event.*; 
import java.awt.*; 
public class RegistrationForm1 extends JFrame 
{ 
    public RegistrationForm1() { 
        initComponents(); 
        pwd_Error.setVisible(false); 
        Firstname_Error.setVisible(false); 
        Email_Error.setVisible(false); 
        jRadioButton1.setActionCommand("Female"); 
        jRadioButton2.setActionCommand("Male"); 
        jRadioButton3.setActionCommand("Civil"); 
        jRadioButton4.setActionCommand("Computer Science and Engineering"); 
        jRadioButton5.setActionCommand("Electrical"); 
        jRadioButton6.setActionCommand("Electronics and Commnication"); 
        jRadioButton7.setActionCommand("Mechanical"); 
         
    } 
private void jRadioButton7ActionPerformed(ActionEvent evt) {                                         
            }                                              
 
private void jTextField1FocusLost(FocusEvent evt) 
{                                       
    if(jTextField1.getText().equals("")) 
    { 
        Firstname_Error.setVisible(true); 
        jTextField1.setFocusable(true); 
        jTextField1.requestFocus(true); 
    } 
    else 
    { 
        Firstname_Error.setVisible(false); 
    } 
}                                      
 
private void jToggleButton1ActionPerformed(ActionEvent evt) 
{                                                
jTextArea1.setText("Name : "+jTextField1.getText()+"\n" 
               +"Surname : "+jTextField2.getText()+"\n" 
                       +"Email Address : "+jTextField3.getText()+"\n" 
       +"Date Of Birth : "+jComboBox1.getSelectedItem().toString()+" 
"+jComboBox2.getSelectedItem().toString()+" 
"+jComboBox3.getSelectedItem().toString()+"\n" 
+"Gender : "+Gender.getSelection().getActionCommand()+"\n" 
                     +"Department : "+Department.getSelection().getActionCommand() 
            ); 
    }                                               
 
private void jToggleButton2ActionPerformed(ActionEvent evt) 
{                                                
System.exit(0); 
}                                               
 
private void jTextField4FocusLost(FocusEvent evt) 
{                                       
        if(jTextField3.getText().equals(jTextField4.getText())) 
        { 
            Email_Error.setVisible(false); 
        } 
        else 
        { 
            Email_Error.setVisible(true); 
            jTextField3.setFocusable(true); 
            jTextField3.requestFocus(); 
        } 
}                                      
 
private void jPasswordField2FocusLost(java.awt.event.FocusEvent evt) 
{                                           
        if(jPasswordField1.getText().equals(jPasswordField2.getText())) 
        { 
            pwd_Error.setVisible(false); 
        } 
        else 
        { 
            pwd_Error.setVisible(true); 
            jPasswordField1.setFocusable(true); 
            jPasswordField1.requestFocus(); 
        } 
}                                          
public static void main(String args[]) 
{ 
  
       try { 
            for (javax.swing.UIManager.LookAndFeelInfo info : 
javax.swing.UIManager.getInstalledLookAndFeels()) { 
                if ("Nimbus".equals(info.getName())) { 
                    javax.swing.UIManager.setLookAndFeel(info.getClassName()); 
                    break; 
                } 
            } 
        } catch (ClassNotFoundException | InstantiationException | 
IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { 
            
java.util.logging.Logger.getLogger(RegistrationForm1.class.getName()).log(java.util.lo
gging.Level.SEVERE, null, ex); 
        } 
         
 
        /* Create and display the form */ 
        java.awt.EventQueue.invokeLater(new Runnable() { 
                       public void run() { 
                new RegistrationForm1().setVisible(true); 
            } 
        }); 
    } 
    // Variables declaration - do not modify                      
    private JLabel Data_Below; 
    private ButtonGroup Department; 
    private Label Email_Error; 
    private JLabel Firstname_Error; 
    private JButtonGroup Gender; 
    private JComboBox jComboBox1; 
    private JComboBox jComboBox2; 
    private JComboBox jComboBox3; 
    private JLabel jLabel1; 
    private JLabel jLabel11; 
    private JLabel jLabel3; 
    private JLabel jLabel4; 
    private JLabel jLabel5; 
    private JLabel jLabel6; 
    private JLabel jLabel7; 
    private JLabel jLabel8; 
    private JLabel jLabel9; 
    private JPasswordField jPasswordField1; 
    private JPasswordField jPasswordField2; 
    private JRadioButton jRadioButton1; 
    private JRadioButton jRadioButton2; 
    private JRadioButton jRadioButton3; 
    private JRadioButton jRadioButton4; 
    private JRadioButton jRadioButton5; 
    private JRadioButton jRadioButton6; 
    private JRadioButton jRadioButton7; 
    private JScrollPane jScrollPane1; 
    private JTextArea jTextArea1; 
    private JTextField jTextField1; 
    private JTextField jTextField2; 
    private JTextField jTextField3; 
    private JTextField jTextField4; 
    private JToggleButton jToggleButton1; 
    private JToggleButton jToggleButton2; 
    private JLabel pwd_Error; 
    // End of variables declaration                    
} 

1 comment: