Featured Post

Friday, February 28, 2020

Design home page using awt and swings


 /* home page using awt and swings */
 /* home page using JApplets */

import javax.swing.*;
import java.awt.event.*;
public class homepage extends JApplet implements ActionListener
{
   JLabel l1,l2,l3,l4,l5,l6;
   JTextField t1,t2,t3;
   JRadioButton rb1,rb2;
   ButtonGroup gender;
   JCheckBox c1,c2,c3,c4;
   JComboBox<String> j1;
    public void init()          
    {
     setLayout(null);
     l1=new JLabel("Enter your First name");
     l1.setSize(300,20);
     l1.setLocation(100,100);  add(l1);
     t1=new JTextField();
     t1.setSize(100,20);
     t1.setLocation(300,100);  add(t1);
     l2=new JLabel("Enter your Email id");
     l2.setSize(300,20);
     l2.setLocation(100,130);
     add(l2); 
     t2=new JTextField();
     t2.setSize(100,20);
     t2.setLocation(300,130);
     add(t2);
     JLabel l3=new JLabel("Select gender");
     l3.setSize(100,20);
     l3.setLocation(100,160);
     add(l3);
     rb1=new JRadioButton("male");
     rb1.setSize(100,20);
     rb1.setLocation(300,160); 
     rb2=new JRadioButton("female");
     rb2.setSize(100,20);
     rb2.setLocation(400,160);
     add(rb1);
     add(rb2);
     gender=new ButtonGroup();
     gender.add(rb1);
     gender.add(rb2);
     l4=new JLabel("Select Your Born Year");
     l4.setSize(150,20);
     l4.setLocation(100,190);
     add(l4);
     j1=new JComboBox<String>();
     j1.addItem("Select");
     j1.addItem("1990");
     j1.addItem("1991");
     j1.setSize(100,20);
     j1.setLocation(300,190);
     add(j1);
     JLabel l4=new JLabel("Select your qualification");
     l4.setSize(150,20);
     l4.setLocation(100,220);
     add(l4);
     c1=new JCheckBox("ssc");
     c1.setSize(100,20);
     c1.setLocation(250,220);
     add(c1);
     c2=new JCheckBox("Inter");
     c2.setSize(100,20);
     c2.setLocation(350,220);
     add(c2);
     c3=new JCheckBox("Degree");
     c3.setSize(100,20);
     c3.setLocation(450,220);
     add(c3);
     c4=new JCheckBox("PG");
     c4.setSize(100,20);
     c4.setLocation(550,220);
     add(c4);
     JButton b1=new JButton("submit");
     b1.setSize(100,20);
     b1.setLocation(100,250);
     add(b1);
     JButton b2=new JButton("reset");
     b2.setSize(100,20);
     b2.setLocation(300,250);
     add(b2);
     l6=new JLabel("");
     l6.setSize(300,20);
     l6.setLocation(100,300);
     add(l6);
     b1.addActionListener(this);
     b2.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
      String str=e.getActionCommand();
     if(str.equals("submit"))
     {
       cleardata();
       l6.setText("Your Form is submitted");  
     };    
     if(str.equals("reset"))
     {
       cleardata();
       l6.setText("Please enter the details again");
    }
  }
    public void cleardata()
    {
      String cl="";
      t1.setText(cl);
     t2.setText(cl);
     c1.setSelected(false);   
     c2.setSelected(false);
     c3.setSelected(false);
     c4.setSelected(false);   
     j1.setSelectedIndex(0);
     gender.clearSelection();
   }     
}

*****************************************************************

<html>
<body>
<applet code="homepage.class" width=150 height=50>
</applet>
</body>

</html>

********************************************************************
Output:




Tags:
Design home page using awt and swings, design home page using swings and awt,
Design home page using awt and swing, design home page using swing and awt, design home page using JApplets, Design a web page using awt and swings, design a form using awt and swings,
Form validation using swings, form validation using awt and swings, connect home page to oracle using swings. connecting swing programs to back end, connecting swings programs to oracle, swings and mysql, swings and oracle, jdbc-odbc program, develop swing programs using JButton , JLabel, JRadioButton ,JCheckBox, JComboBox, Swing programs using JComboBox


No comments:

Post a Comment