0% found this document useful (0 votes)
187 views8 pages

New JFrame 1

The document contains code for a Java Swing registration form GUI with labels, text fields, combo boxes, radio buttons, check boxes, and buttons to collect user information like name, date of birth, address, country, sex, and hobbies. The form uses common Swing components and layouts to arrange these elements on the form.

Uploaded by

jayesh30sikchi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views8 pages

New JFrame 1

The document contains code for a Java Swing registration form GUI with labels, text fields, combo boxes, radio buttons, check boxes, and buttons to collect user information like name, date of birth, address, country, sex, and hobbies. The form uses common Swing components and layouts to arrange these elements on the form.

Uploaded by

jayesh30sikchi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

import javax.swing.

*;
import javax.swing.undo.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
public class NewJFrame1 extends JFrame {
/** Creates new form NewJFrame1 */
public NewJFrame1() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:i
nitComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jComboBox3 = new javax.swing.JComboBox();
jLabel4 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jComboBox4 = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jLabel7 = new javax.swing.JLabel();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
jCheckBox3 = new javax.swing.JCheckBox();
jCheckBox4 = new javax.swing.JCheckBox();
jCheckBox5 = new javax.swing.JCheckBox();
jCheckBox6 = new javax.swing.JCheckBox();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setBackground(javax.swing.UIManager.getDefaults().getColor("Butt
on.focus"));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(10, 8, 8));
jLabel1.setText("Registration Form");
jLabel2.setText("Your Name");
jLabel3.setText("Date Of Birth");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"Date","1" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"Month"}));
jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"Year" }));
jLabel4.setText("Address");
jLabel5.setText("Country");
jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
"India" }));
jLabel6.setText("Sex");
jRadioButton1.setText("Male");
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
jRadioButton2.setText("Female");
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
jLabel7.setText("Your Hobbies");
jCheckBox1.setText("Music");
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1ActionPerformed(evt);
}
});
jCheckBox2.setText("Painting");
jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox2ActionPerformed(evt);
}
});
jCheckBox3.setText("Dance");
jCheckBox3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox3ActionPerformed(evt);
}
});
jCheckBox4.setText("Reading");
jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox4ActionPerformed(evt);
}
});
jCheckBox5.setText("Sports");
jCheckBox5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox5ActionPerformed(evt);
}
});
jCheckBox6.setText("Trekking");
jCheckBox6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox6ActionPerformed(evt);
}
});
jButton1.setText("Clear");
jButton2.setText("Submit");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentP
ane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZ
E, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(225, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(121, 121, 121)
.addComponent(jLabel1)
.addContainerGap(213, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 64,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZ
E, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(192, 192, 192))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 7
1, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(377, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem
ent.RELATED)
.addComponent(jCheckBox6))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addComponent(jCheckBox1)
.addComponent(jCheckBox3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem
ent.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addComponent(jCheckBox4)
.addComponent(jCheckBox2))))
.addContainerGap(298, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.
createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFE
RRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFE
RRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jComboBox4, javax.swing.GroupLayou
t.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.
PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.Compone
ntPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.TRAILING)
.addComponent(jButton1, javax.swing.GroupLay
out.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jRadioButton1)
.addPreferredGap(javax.swing.LayoutStyle
.ComponentPlacement.RELATED)
.addComponent(jRadioButton2)))
.addPreferredGap(javax.swing.LayoutStyle.Compone
ntPlacement.RELATED, 44, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.
PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem
ent.RELATED))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.
createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacem
ent.UNRELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRE
D_SIZE)
.addGap(18, 18, 18)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRE
D_SIZE)
.addGap(18, 18, 18)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFER
RED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(144, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createS
equentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED
_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(49, 49, 49)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRE
D_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout
.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFE
RRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.P
REFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PRE
FERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLa
yout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jComboBox2, javax.swing.GroupLayout.PR
EFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREF
ERRED_SIZE)
.addComponent(jComboBox3, javax.swing.GroupLayout.PR
EFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREF
ERRED_SIZE))))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZ
E, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED
_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_S
IZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jLabel5)
.addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_
SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SI
ZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jLabel6)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 2
3, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA
TED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jCheckBox1)
.addComponent(jCheckBox2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jCheckBox3)
.addComponent(jCheckBox4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jCheckBox5)
.addComponent(jCheckBox6))
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton1))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jComboBox1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jComboBox1ActionPerformed
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {/
/GEN-FIRST:event_jRadioButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jRadioButton1ActionPerformed
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {/
/GEN-FIRST:event_jRadioButton2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jRadioButton2ActionPerformed
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox1ActionPerformed
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox2ActionPerformed
private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox3ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox3ActionPerformed
private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox4ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox4ActionPerformed
private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox5ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox5ActionPerformed
private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GE
N-FIRST:event_jCheckBox6ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox6ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame1().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JCheckBox jCheckBox5;
private javax.swing.JCheckBox jCheckBox6;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JComboBox jComboBox4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
}

You might also like