Showing posts with label Java Swing Registration Form. Show all posts
Showing posts with label Java Swing Registration Form. Show all posts

Tuesday, June 11, 2024

Simple Registration Form Java Swing

//Simple Registration Form Swing

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;


public class Form extends JFrame implements ActionListener 

{

JFrame f;

JLabel l1,l2,l3,l4,l5,l6;

JTextField t1,t2;

JPasswordField p1;

JComboBox cb1;

JTextArea ta;

JScrollPane sp1;

JButton b1,b2;


public Form()

{

f=new JFrame("Register Form");

l6=new JLabel("REGISTER FORM");

l6.setBounds(200,5,250,100);

l6.setFont(new Font("Lucida Sans",Font.BOLD,30));

l1=new JLabel("Name");

l1.setBounds(150,100,150,30);

l1.setFont(new Font("Lucida Sans",Font.BOLD,13));


l2=new JLabel("Password");

l2.setBounds(150,160,200,30);

l2.setFont(new Font("Lucida Sans",Font.BOLD,13));

l3=new JLabel("Address");

l3.setBounds(150,220,250,30);

l3.setFont(new Font("Lucida Sans",Font.BOLD,13));


l4=new JLabel("City");

l4.setBounds(150,345,350,30);

l4.setFont(new Font("Lucida Sans",Font.BOLD,13));


l5=new JLabel("Phone");

l5.setBounds(150,410,400,30);

l5.setFont(new Font("Lucida Sans",Font.BOLD,13));


t1=new JTextField();

t1.setBounds(250,100,250,35);

t1.setFont(new Font("Lucida Sans",Font.BOLD,13));


p1=new JPasswordField();

p1.setBounds(250,160,250,35);

p1.setFont(new Font("Lucida Sans",Font.BOLD,13));


ta=new JTextArea();

sp1=new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,

     JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

sp1.setBounds(250,220,250,100);

ta.setFont(new Font("Lucida Sans",Font.BOLD,13));

String []ct={"Rajkot","Gondal","Virpur","Jetpur","Junagadh"};

cb1=new JComboBox(ct);

cb1.setBounds(250,345,250,35);

cb1.setFont(new Font("Lucida Sans",Font.BOLD,13));

t2=new JTextField();

t2.setBounds(250,410,250,35);

t2.setFont(new Font("Lucida Sans",Font.BOLD,13));


b1=new JButton("Submit");

b1.setBounds(250,480,100,50);

b1.addActionListener(this);

b1.setFont(new Font("Lucida Sans",Font.BOLD,13));


b2=new JButton("Cancle");

b2.setBounds(400,480,100,50);

b2.addActionListener(this);

b2.setFont(new Font("Lucida Sans",Font.BOLD,13));


f.add(l6);

f.add(l1);

f.add(t1);

f.add(l2);

f.add(p1);

f.add(l3);

f.add(sp1);

f.add(l4);

f.add(cb1);

f.add(l5);

f.add(t2);

f.add(b1);

f.add(b2);

f.setLayout(null);

f.setSize(500,500);

f.setVisible(true);

}

public void actionPerformed(ActionEvent ae)

{

if(ae.getSource()==b1)

{

JOptionPane.showMessageDialog(null,"Submitted Successfully!!");

}

if(ae.getSource()==b2)

{

System.exit(0);

}

}

public static void main(String args[])

{

new Form();

}

}


Output :-