0% found this document useful (0 votes)
12 views33 pages

English

The document contains code for four Java Swing applications: an Application Form, a BMI Calculator, a Contact Us form, and a Month Year selector. Each application includes a graphical user interface with various input fields, buttons, and labels, designed for user interaction. The code demonstrates the use of panels, layout managers, and event handling in Java Swing to create functional desktop applications.

Uploaded by

zun zun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views33 pages

English

The document contains code for four Java Swing applications: an Application Form, a BMI Calculator, a Contact Us form, and a Month Year selector. Each application includes a graphical user interface with various input fields, buttons, and labels, designed for user interaction. The code demonstrates the use of panels, layout managers, and event handling in Java Swing to create functional desktop applications.

Uploaded by

zun zun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Lab 2

Run the following programs.


1. Application Form
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.GridLayout;
import javax.swing.DefaultComboBoxModel;

public class ApplicationForm extends JFrame {


private JPanel contentPane;
private JTextField textField;

/**
* Launch the application.
*/
public static void main(String[] args) {
// ApplicationForm applicationForm = new ApplicationForm();
// applicationForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// applicationForm.setVisible(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ApplicationForm frame = new ApplicationForm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public ApplicationForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 579, 561);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
contentPane.setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(5, 6, 536, 67);
contentPane.add(panel);
panel.setLayout(null);

JLabel lblNewLabel = new JLabel("Application Form");


lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
lblNewLabel.setBounds(161, 0, 182, 41);
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();


panel_1.setBounds(5, 73, 536, 67);
contentPane.add(panel_1);
panel_1.setLayout(null);
JLabel lblNewLabel_1 = new JLabel("Name");
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_1.setBounds(10, 0, 139, 30);
panel_1.add(lblNewLabel_1);

textField = new JTextField();


textField.setBounds(159, 0, 367, 30);
panel_1.add(textField);
textField.setColumns(10);

JPanel panel_2 = new JPanel();


panel_2.setBounds(5, 140, 536, 67);
contentPane.add(panel_2);
panel_2.setLayout(null);

JLabel lblNewLabel_2 = new JLabel("Gender");


lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_2.setBounds(10, 11, 144, 30);
panel_2.add(lblNewLabel_2);

JRadioButton rdbtnNewRadioButton = new JRadioButton("Female");


rdbtnNewRadioButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
rdbtnNewRadioButton.setBounds(185, 15, 111, 23);
panel_2.add(rdbtnNewRadioButton);

JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("Male");


rdbtnNewRadioButton_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
rdbtnNewRadioButton_1.setBounds(371, 15, 111, 23);
panel_2.add(rdbtnNewRadioButton_1);

JPanel panel_3 = new JPanel();


panel_3.setBounds(5, 207, 536, 67);
contentPane.add(panel_3);
panel_3.setLayout(null);

JLabel lblNewLabel_2_1 = new JLabel("Interest");


lblNewLabel_2_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_2_1.setBounds(10, 11, 144, 30);
panel_3.add(lblNewLabel_2_1);

JCheckBox chckbxNewCheckBox = new JCheckBox("Reading");


chckbxNewCheckBox.setFont(new Font("Tahoma", Font.PLAIN, 20));
chckbxNewCheckBox.setBounds(188, 11, 99, 23);
panel_3.add(chckbxNewCheckBox);

JCheckBox chckbxProgramming = new JCheckBox("Programming");


chckbxProgramming.setFont(new Font("Tahoma", Font.PLAIN, 20));
chckbxProgramming.setBounds(368, 11, 152, 23);
panel_3.add(chckbxProgramming);

JPanel panel_4 = new JPanel();


panel_4.setBounds(5, 274, 536, 67);
contentPane.add(panel_4);
panel_4.setLayout(null);

JLabel lblNewLabel_2_2 = new JLabel("Favourite Place");


lblNewLabel_2_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_2_2.setBounds(10, 0, 144, 30);
panel_4.add(lblNewLabel_2_2);

JComboBox comboBox = new JComboBox();


comboBox.setFont(new Font("Tahoma", Font.PLAIN, 20));
comboBox.setModel(new DefaultComboBoxModel(new String[] {"Bagan",
"NayPyiTaw", "Yangon", "Mandalay"}));
comboBox.setBounds(164, 8, 362, 48);
panel_4.add(comboBox);
JPanel panel_5 = new JPanel();
panel_5.setBounds(5, 341, 536, 108);
contentPane.add(panel_5);
panel_5.setLayout(null);

JLabel lblNewLabel_2_3 = new JLabel("Detail");


lblNewLabel_2_3.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_2_3.setBounds(10, 0, 144, 30);
panel_5.add(lblNewLabel_2_3);

JTextArea textArea = new JTextArea();


textArea.setBounds(164, 7, 362, 90);
panel_5.add(textArea);

JPanel panel_6 = new JPanel();


panel_6.setBounds(5, 446, 536, 67);
contentPane.add(panel_6);
panel_6.setLayout(null);

JButton btnNewButton = new JButton("Submit");


btnNewButton.setBounds(82, 5, 118, 33);
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_6.add(btnNewButton);

JButton btnNewButton_1 = new JButton("Exit");


btnNewButton_1.setBounds(347, 5, 95, 33);
btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_6.add(btnNewButton_1);
}
}

2. BMI Calculator

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JRadioButton;
import java.awt.GridLayout;

public class BMIcalculator extends JFrame {


private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
/**
* Launch the application.
*/
public static void main(String[] args) {
// BMIcalculator BMIcalculator = new BMIcalculator();
// BMIcalculator.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// BMIcalculator.setVisible(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BMIcalculator frame = new BMIcalculator();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public BMIcalculator() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 451, 609);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
contentPane.setLayout(new GridLayout(0, 1, 0, 0));
JPanel panel = new JPanel();
contentPane.add(panel);
panel.setLayout(null);

JLabel lblNewLabel = new JLabel("BMI Calculator");


lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
lblNewLabel.setBounds(80, 11, 161, 23);
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();


contentPane.add(panel_1);
panel_1.setLayout(null);

textField = new JTextField();


textField.setBounds(155, 11, 261, 34);
panel_1.add(textField);
textField.setColumns(10);

JLabel lblName = new JLabel("Name");


lblName.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblName.setBounds(0, 11, 83, 23);
panel_1.add(lblName);

JPanel panel_1_1 = new JPanel();


contentPane.add(panel_1_1);
panel_1_1.setLayout(null);

textField_1 = new JTextField();


textField_1.setColumns(10);
textField_1.setBounds(155, 11, 261, 34);
panel_1_1.add(textField_1);

JLabel lblAge = new JLabel("Age");


lblAge.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblAge.setBounds(0, 11, 83, 23);
panel_1_1.add(lblAge);

JPanel panel_1_2 = new JPanel();


contentPane.add(panel_1_2);
panel_1_2.setLayout(null);

JLabel lblGender = new JLabel("Gender");


lblGender.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblGender.setBounds(0, 11, 83, 23);
panel_1_2.add(lblGender);

JRadioButton rdbtnNewRadioButton = new JRadioButton("Female");


rdbtnNewRadioButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
rdbtnNewRadioButton.setBounds(299, 15, 111, 23);
panel_1_2.add(rdbtnNewRadioButton);

JRadioButton rdbtnMale = new JRadioButton("Male");


rdbtnMale.setSelected(true);
rdbtnMale.setFont(new Font("Tahoma", Font.PLAIN, 20));
rdbtnMale.setBounds(165, 15, 111, 23);
panel_1_2.add(rdbtnMale);

JPanel panel_1_3 = new JPanel();


contentPane.add(panel_1_3);
panel_1_3.setLayout(null);

textField_2 = new JTextField();


textField_2.setColumns(10);
textField_2.setBounds(155, 11, 261, 34);
panel_1_3.add(textField_2);

JLabel lblHeight = new JLabel("Height");


lblHeight.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblHeight.setBounds(0, 21, 83, 23);
panel_1_3.add(lblHeight);

JPanel panel_1_4 = new JPanel();


contentPane.add(panel_1_4);
panel_1_4.setLayout(null);

textField_3 = new JTextField();


textField_3.setColumns(10);
textField_3.setBounds(155, 11, 261, 34);
panel_1_4.add(textField_3);

JLabel lblWeight = new JLabel("Weight");


lblWeight.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblWeight.setBounds(0, 13, 83, 23);
panel_1_4.add(lblWeight);

JPanel panel_1_5 = new JPanel();


contentPane.add(panel_1_5);
panel_1_5.setLayout(null);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_4.setBounds(155, 11, 261, 34);
panel_1_5.add(textField_4);

JLabel lblResult = new JLabel("Result");


lblResult.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblResult.setBounds(0, 21, 83, 23);
panel_1_5.add(lblResult);

JPanel panel_1_6 = new JPanel();


contentPane.add(panel_1_6);
panel_1_6.setLayout(null);
JButton btnNewButton = new JButton("Submit");
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButton.setBounds(125, 11, 162, 45);
panel_1_6.add(btnNewButton);
}
}

3. Contact Us!

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.*;
public class ContactusForm extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ContactusForm frame = new ContactusForm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public ContactusForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 466, 399);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(10, 10, 196, 46);
contentPane.add(panel);
panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

JLabel lblNewLabel = new JLabel("Contact Us!");


lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();


panel_1.setBounds(10, 67, 423, 94);
contentPane.add(panel_1);
panel_1.setLayout(new GridLayout(0, 1, 0, 0));

JLabel lblNewLabel_1 = new JLabel("E-mail Address");


lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_1.add(lblNewLabel_1);
textField = new JTextField();
panel_1.add(textField);
textField.setColumns(10);

JPanel panel_1_1 = new JPanel();


panel_1_1.setBounds(10, 170, 423, 94);
contentPane.add(panel_1_1);
panel_1_1.setLayout(new GridLayout(0, 1, 0, 0));

JLabel lblNewLabel_1_1 = new JLabel("Your Message");


lblNewLabel_1_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_1_1.add(lblNewLabel_1_1);
textField_1 = new JTextField();
textField_1.setColumns(10);
panel_1_1.add(textField_1);

JPanel panel_2 = new JPanel();


panel_2.setBounds(10, 275, 423, 60);
contentPane.add(panel_2);
panel_2.setLayout(null);

JButton btnNewButton = new JButton("Submit");


btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

}
});
btnNewButton.setBounds(140, 11, 143, 44);
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_2.add(btnNewButton);
}

4. Month Year

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.JButton;
import java.awt.GridLayout;
import javax.swing.DefaultComboBoxModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MonthYear extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MonthYear frame = new MonthYear();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public MonthYear() {
setTitle("Calendar");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 489, 381);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
contentPane.setLayout(new GridLayout(0, 1, 0, 0));

JPanel panel = new JPanel();


contentPane.add(panel);

JLabel lblNewLabel = new JLabel("Month and Year");


lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();


contentPane.add(panel_1);
panel_1.setLayout(null);

JLabel lblNewLabel_1 = new JLabel("Month");


lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_1.setBounds(10, 11, 114, 18);
panel_1.add(lblNewLabel_1);

JComboBox comboBox = new JComboBox();


comboBox.setFont(new Font("Tahoma", Font.PLAIN, 20));
comboBox.setModel(new DefaultComboBoxModel(new String[] {"January",
"February", "March", "April", "May", "June", "July", "August", "September", "October",
"November", "December"}));
comboBox.setBounds(133, 13, 208, 43);
panel_1.add(comboBox);

JPanel panel_1_1 = new JPanel();


panel_1_1.setLayout(null);
contentPane.add(panel_1_1);
JLabel lblNewLabel_1_1 = new JLabel("Year");
lblNewLabel_1_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_1_1.setBounds(10, 11, 114, 18);
panel_1_1.add(lblNewLabel_1_1);

JComboBox comboBox_1 = new JComboBox();


comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"2000", "2001",
"2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012",
"2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023",
"2024", "2025"}));
comboBox_1.setSelectedIndex(24);
comboBox_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
comboBox_1.setBounds(133, 13, 204, 25);
panel_1_1.add(comboBox_1);

JPanel panel_2 = new JPanel();


contentPane.add(panel_2);

JButton btnNewButton = new JButton("Enter");


btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(btnNewButton,"Success");

}
});
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_2.add(btnNewButton);
}
}

5. Music Application

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MusicApp extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;
private JTextField textField;
private JTextField txtEnterSongName;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MusicApp frame = new MusicApp();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MusicApp() {
setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\Admin\\Pictures\\
Screenshots\\Screenshot 2024-09-03 053147.png"));
setTitle("Music App Form");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 419, 378);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new GridLayout(0, 1, 0, 0));

JPanel panel = new JPanel();


contentPane.add(panel);
panel.setLayout(null);

JLabel lblNewLabel = new JLabel("Music Application");


lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 23));
lblNewLabel.setBounds(10, 11, 373, 31);
panel.add(lblNewLabel);

JPanel panel_2 = new JPanel();


contentPane.add(panel_2);
panel_2.setLayout(null);

textField = new JTextField();


textField.setBounds(10, 11, 369, 31);
textField.setText("Enter Artist Name");
textField.setFont(new Font("Tahoma", Font.PLAIN, 20));
textField.setColumns(10);
panel_2.add(textField);
JPanel panel_2_1 = new JPanel();
panel_2_1.setLayout(null);
contentPane.add(panel_2_1);

txtEnterSongName = new JTextField();


txtEnterSongName.setText("Enter Song Name");
txtEnterSongName.setFont(new Font("Tahoma", Font.PLAIN, 20));
txtEnterSongName.setColumns(10);
txtEnterSongName.setBounds(10, 11, 369, 31);
panel_2_1.add(txtEnterSongName);

JPanel panel_1 = new JPanel();

contentPane.add(panel_1);
panel_1.setLayout(null);

JButton btnNewButton = new JButton("Submit");


btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButton.setBounds(10, 0, 139, 43);
panel_1.add(btnNewButton);

JButton btnClearAll = new JButton("Clear All");


btnClearAll.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textField.setText("");
txtEnterSongName.setText("");
}
});
btnClearAll.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnClearAll.setBounds(218, 0, 139, 43);
panel_1.add(btnClearAll);
}
}

6. Welcome Guest

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.JCheckBox;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class WelcomeGuest extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;
private JTextField textField;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WelcomeGuest frame = new WelcomeGuest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public WelcomeGuest() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 465, 401);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
contentPane.setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(10, 0, 426, 48);
contentPane.add(panel);

JLabel lblNewLabel = new JLabel("Welcome Guest");


lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel.add(lblNewLabel);

JPanel panel_1 = new JPanel();


panel_1.setBounds(10, 59, 426, 53);
contentPane.add(panel_1);
panel_1.setLayout(null);

JLabel lblNewLabel_1 = new JLabel("Your Age:");


lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_1.setBounds(0, 4, 145, 37);
panel_1.add(lblNewLabel_1);
textField = new JTextField();
textField.setBounds(156, 11, 270, 31);
panel_1.add(textField);
textField.setColumns(10);

JPanel panel_2 = new JPanel();


panel_2.setBounds(10, 123, 163, 41);
contentPane.add(panel_2);
panel_2.setLayout(null);

JLabel lblNewLabel_1_1 = new JLabel("Your Hobbies");


lblNewLabel_1_1.setBounds(0, 5, 153, 25);
lblNewLabel_1_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_2.add(lblNewLabel_1_1);

JPanel panel_3 = new JPanel();


panel_3.setBounds(183, 123, 253, 157);
contentPane.add(panel_3);
panel_3.setLayout(new GridLayout(0, 1, 0, 0));

JCheckBox chckbxProgramming = new JCheckBox("Programming");


chckbxProgramming.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(chckbxProgramming);

JCheckBox chckbxReading = new JCheckBox("Reading");


chckbxReading.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(chckbxReading);

JCheckBox chckbxNewCheckBox = new JCheckBox("Swimming");


chckbxNewCheckBox.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(chckbxNewCheckBox);

JCheckBox chckbxNetworking = new JCheckBox("Networking");


chckbxNetworking.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(chckbxNetworking);

JPanel panel_4 = new JPanel();


panel_4.setBounds(183, 304, 232, 49);
contentPane.add(panel_4);
panel_4.setLayout(null);

JButton btnNewButton = new JButton("Next");


btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButton.setBounds(71, 5, 130, 33);
panel_4.add(btnNewButton);
}

7. Contact

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridLayout;

public class Contact extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Contact frame = new Contact();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public Contact() {
setTitle("Contact Information");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 430, 313);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(5, 5, 407, 107);
contentPane.add(panel);
panel.setLayout(null);

JLabel lblNewLabel = new JLabel("Name");


lblNewLabel.setBounds(33, 11, 97, 23);
panel.add(lblNewLabel);

JLabel lblYour = new JLabel("Date of Birth");


lblYour.setBounds(33, 37, 97, 23);
panel.add(lblYour);

JLabel lblNewLabel_1 = new JLabel("-----------------------------------");


lblNewLabel_1.setBounds(200, 15, 165, 14);
panel.add(lblNewLabel_1);

JLabel lblNewLabel_1_1 = new JLabel("-----------------------------------");


lblNewLabel_1_1.setBounds(200, 41, 165, 14);
panel.add(lblNewLabel_1_1);

JPanel panel_1 = new JPanel();


panel_1.setBounds(5, 112, 407, 107);
contentPane.add(panel_1);
panel_1.setLayout(null);

JLabel lblNewLabel_2 = new JLabel("Your Contact Details");


lblNewLabel_2.setBounds(10, 11, 208, 14);
panel_1.add(lblNewLabel_2);

JLabel lblNewLabel_3 = new JLabel("Email*");


lblNewLabel_3.setBounds(20, 43, 49, 14);
panel_1.add(lblNewLabel_3);

JLabel lblNewLabel_3_1 = new JLabel("Mobile Number*");


lblNewLabel_3_1.setBounds(20, 75, 100, 14);
panel_1.add(lblNewLabel_3_1);

textField = new JTextField();


textField.setBounds(196, 40, 163, 20);
panel_1.add(textField);
textField.setColumns(10);

textField_1 = new JTextField();


textField_1.setColumns(10);
textField_1.setBounds(196, 75, 163, 20);
panel_1.add(textField_1);

JPanel panel_2 = new JPanel();


panel_2.setBounds(5, 219, 407, 46);
contentPane.add(panel_2);
panel_2.setLayout(null);

JButton btnNewButton = new JButton("Ok");


btnNewButton.setBounds(53, 11, 89, 23);
panel_2.add(btnNewButton);

JButton btnCancel = new JButton("Cancel");


btnCancel.setBounds(226, 11, 89, 23);
panel_2.add(btnCancel);
}
}

8. Sign Up

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.FlowLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import javax.swing.SwingConstants;
import java.awt.CardLayout;
import javax.swing.BoxLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SignUP extends JFrame {

private static final long serialVersionUID = 1L;


private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SignUP frame = new SignUP();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public SignUP() {
setTitle("Sign Up Form");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 432, 609);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
contentPane.setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(10, 70, 385, 409);
contentPane.add(panel);
panel.setLayout(new GridLayout(0, 1, 0, 0));

JPanel panel_1 = new JPanel();


panel.add(panel_1);
panel_1.setLayout(null);

JLabel lblNewLabel_1 = new JLabel("Full name");


lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblNewLabel_1.setBounds(25, 5, 161, 36);
panel_1.add(lblNewLabel_1);

textField = new JTextField();


textField.setBounds(25, 52, 249, 20);
panel_1.add(textField);
textField.setColumns(10);

JPanel panel_1_1 = new JPanel();


panel_1_1.setLayout(null);
panel.add(panel_1_1);

JLabel lblNewLabel_1_1 = new JLabel("Email");


lblNewLabel_1_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblNewLabel_1_1.setBounds(25, 5, 161, 36);
panel_1_1.add(lblNewLabel_1_1);

textField_1 = new JTextField();


textField_1.setColumns(10);
textField_1.setBounds(25, 52, 249, 20);
panel_1_1.add(textField_1);

JPanel panel_1_1_1 = new JPanel();


panel_1_1_1.setLayout(null);
panel.add(panel_1_1_1);

JLabel lblNewLabel_1_1_1 = new JLabel("Password");


lblNewLabel_1_1_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblNewLabel_1_1_1.setBounds(25, 5, 161, 36);
panel_1_1_1.add(lblNewLabel_1_1_1);

textField_2 = new JTextField();


textField_2.setColumns(10);
textField_2.setBounds(25, 52, 249, 20);
panel_1_1_1.add(textField_2);

JPanel panel_1_1_1_1 = new JPanel();


panel_1_1_1_1.setLayout(null);
panel.add(panel_1_1_1_1);

JButton btnNewButton = new JButton("Sign Up");


btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 15));
btnNewButton.setBounds(10, 30, 102, 36);
panel_1_1_1_1.add(btnNewButton);

JPanel panel_2 = new JPanel();


panel_2.setBounds(10, 507, 385, 56);
contentPane.add(panel_2);
panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

JLabel lblNewLabel_2 = new JLabel("I've an account");


lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 15));
panel_2.add(lblNewLabel_2);

JLabel label = new JLabel("");


panel_2.add(label);

JButton btnNewButton_1 = new JButton("Login");


btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LoginForm loginform=new LoginForm();
loginform.frmLoginForm.setVisible(true);
}
});
btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
panel_2.add(btnNewButton_1);

JPanel panel_3 = new JPanel();


panel_3.setBounds(10, 11, 385, 39);
contentPane.add(panel_3);
panel_3.setLayout(new BorderLayout(0, 0));

JLabel lblNewLabel = new JLabel("Sign Up");


lblNewLabel.setVerticalAlignment(SwingConstants.TOP);
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
panel_3.add(lblNewLabel);
}
}

9.Login Form
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JButton;
import java.awt.FlowLayout;
import javax.swing.JTextField;

public class LoginForm {

JFrame frmLoginForm;
private JTextField textField;
private JTextField textField_1;
private JButton btnNewButton;
private JLabel lblNewLabel_2;
private JButton btnNewButton_1;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LoginForm window = new LoginForm();
window.frmLoginForm.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public LoginForm() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmLoginForm = new JFrame();
frmLoginForm.setTitle("Login Form");
frmLoginForm.setBounds(100, 100, 464, 394);
frmLoginForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmLoginForm.getContentPane().setLayout(null);

JLabel lblNewLabel = new JLabel("Username");


lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel.setBounds(44, 27, 195, 45);
frmLoginForm.getContentPane().add(lblNewLabel);

textField = new JTextField();


textField.setBounds(44, 83, 344, 20);
frmLoginForm.getContentPane().add(textField);
textField.setColumns(10);

JLabel lblNewLabel_1 = new JLabel("Password");


lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_1.setBounds(44, 132, 274, 20);
frmLoginForm.getContentPane().add(lblNewLabel_1);
textField_1 = new JTextField();
textField_1.setBounds(44, 172, 344, 20);
frmLoginForm.getContentPane().add(textField_1);
textField_1.setColumns(10);

btnNewButton = new JButton("Login");


btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButton.setBounds(44, 235, 109, 33);
frmLoginForm.getContentPane().add(btnNewButton);

lblNewLabel_2 = new JLabel("I don't have an account");


lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel_2.setBounds(8, 306, 231, 25);
frmLoginForm.getContentPane().add(lblNewLabel_2);

btnNewButton_1 = new JButton("Sign Up");


btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnNewButton_1.setBounds(272, 298, 135, 33);
frmLoginForm.getContentPane().add(btnNewButton_1);
}
}

You might also like