JAVA Program using Swing to Design Contact Form

JAVA Program using Swing to Design Contact Form:

import javax.swing.*;
import java.awt.*;

public class swingcontact extends JApplet
{

    swingcontact()
    {
      JFrame  jf= new JFrame("Example of Component");
      JPanel jp1=new JPanel(new GridLayout(5,2));
      JPanel jp2=new JPanel();
      JPanel jp3=new JPanel(new GridLayout(2,2));
      JLabel jl1,jl2,jl3,jl4;
      JTextField jt1,jt2,jt3,jt4,jt5;
      JButton jb1,jb2;
      JComboBox jc1;

      jl1=new JLabel("Name");
      jl2=new JLabel("Address");
      jl3=new JLabel("Contact");
      jl4=new JLabel("Country");

      jt1=new JTextField(20);
      jt2=new JTextField();
      jt3=new JTextField();
      jt4=new JTextField();
      jt5=new JTextField();

      jb1=new JButton("Submit");
      jb1.setSize(3,4);
      jb2=new JButton("Cancel");

      jc1=new JComboBox();
      jc1.addItem("India");
      jc1.addItem("USA");
      jc1.addItem("UK");
      jc1.addItem("Sri lanka");
      jc1.addItem("China");
      jc1.addItem("Nepal");

      jp1.add(jl1);
      jp1.add(jt1);
      jp1.add(jl2);
      jp1.add(jt2);
      jp1.add(jl3);
      jp1.add(jt3);
      jp1.add(jl4);
      jp1.add(jc1);
      jp2.add(jb1);
      jp2.add(jb2);

      jp3.add(jp1);
      jp3.add(jp2);
      jf.add(jp3);
      jf.setVisible(true);
      jf.setSize(400,300);
      jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
  }


    public static void main(String[] args)
    {
       new swingcontact();
    }
}

OUTPUT:

JAVA Program using Swing to Design Contact Form

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.