Showing posts with label awt. Show all posts
Showing posts with label awt. Show all posts

Monday, 17 June 2013

Happy Father's Day


/**
 * @(#)HappyFathersDay.java
 *
 *
 * @author -> Anant Mahale
 * @version 1.00 2013/6/16
 */
import java.awt.*;
import java.awt.event.*;
class ButtonFrame extends Frame implements ActionListener
{
    private Button btn_press;
    public ButtonFrame()
    {
        setLayout(new FlowLayout());
       
        setTitle("Wish");
        setSize(500,500);
        setLocation(200,200);
       
        btn_press=new Button("Wish Your Father");
        btn_press.setForeground(Color.orange);
        btn_press.addActionListener(this);
        add(btn_press);
       
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_press)
        {
            new dailog().setVisible(true);
        }
    }
}
class dailog extends  Dialog implements  ActionListener
{

    private Button btn_yes;
    private Panel north_panel,south_panel;
    public dailog()
    {
       
        super(new ButtonFrame(),"Dialog Demo",true);
        setBackground(Color.darkGray);
        south_panel=new Panel();
       
        setTitle("Father's Day Wishes");
        setSize(700,250);
        setLocation(50,80);
        btn_yes=new Button("Exit");
       
        south_panel.add(btn_yes);
        add(south_panel,"South");
        btn_yes.addActionListener(this);
    }
    public void paint(Graphics g)
    {
        g.setFont(new Font("MV Boli",Font.BOLD,30));
        g.setColor(Color.RED);
        g.drawString("Your guiding hand on my shoulder,",75,80);
        g.drawString("Will remain with me forever.,",75,110);
        g.drawString("Thanks for always being there Papa.",75,140);
        g.drawString("Happy Father’s Day!",75,170);
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_yes)
        {
            System.exit(0);
        }
    }
}
class HappyFathersDay
{
    public static void main(String args[])
    {
        new ButtonFrame().setVisible(true);
    }
}

Sunday, 16 June 2013

Scrollbar demo in java awt


/**
 * @(#)ScrollDemo.java
 *
 *
 * @anant mahale 
 * @version 1.00 2013/3/18
 */
import java.awt.*;
import java.awt.event.*;
class MyScroll extends Frame implements  AdjustmentListener
{
    private Scrollbar scr_red,scr_green,scr_blue;
    private int r,g,b;
    public MyScroll()
    {
        setTitle("Scrollbar");
        setSize(500,500);
        setLocation(100,100);
   
        scr_red=new Scrollbar(Scrollbar.HORIZONTAL,0,45,0,300);
        scr_green=new Scrollbar(Scrollbar.HORIZONTAL,0,45,0,300);
        scr_blue=new Scrollbar(Scrollbar.HORIZONTAL,0,45,0,300);
       
        scr_red.addAdjustmentListener(this);
        scr_green.addAdjustmentListener(this);
        scr_blue.addAdjustmentListener(this);
       
        setLayout(null);
       
        scr_red.setBounds(10,50,200,20);
        scr_green.setBounds(10,80,200,20);
        scr_blue.setBounds(10,110,200,20);
       
        add(scr_red);
        add(scr_green);
        add(scr_blue);
       
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void adjustmentValueChanged(AdjustmentEvent ae)
    {
        if(ae.getSource()==scr_red)
        {
            r=scr_red.getValue();
        }
        else if(ae.getSource()==scr_green)
        {
            g=scr_green.getValue();
        }
        else if(ae.getSource()==scr_blue)
        {
            b=scr_blue.getValue();
        }
        setBackground(new Color(r,g,b));
    }
}
class ScrollDemo
{
    public static void main(String []args)
    {
        new MyScroll().setVisible(true);
    }
}

Frame Demo in Java

import java.awt.*;
class SecondFrame
{
    public static void main(String []args)
    {
        Frame f1=new Frame("This is my second frame");
        f1.setVisible(true);
        f1.setLocation(100,100);
        f1.setResizable(false);
    }
}

Saturday, 15 June 2013

java awt program on echochar OR on password



//wap to enter name & password and print using echochar

import java.awt.*;
import java.awt.event.*;

class myframe extends Frame implements ActionListener
{
    Button b1,b2;
    TextField tx1,tx2;
    Label l1,l2,l3;
    int a;

    myframe()
    {

        setLayout(null);


        l1=new Label("Enter the name");
        l1.setBounds(50,50,150,20);
        l1.setForeground(Color.blue);
        add(l1);

        tx1=new TextField();
        tx1.setBounds(200,50,150,30);
        add(tx1);

        l2=new Label("Enter the password");
        l2.setBounds(50,150,150,30);
        l2.setForeground(Color.blue);
        add(l2);

        tx2=new TextField();
        tx2.setEchoChar('*');
        tx2.setBounds(200,150,150,30);
        add(tx2);



        b1=new Button("Display");
        b1.addActionListener(this);
        b1.setBounds(100,260,90,50);
        add(b1);

        b2=new Button("Exit");
        b2.addActionListener(this);
        b2.setBounds(210,260,90,50);
        add(b2);

    }
    public void paint(Graphics g)
    {
        if(a==1)
        {
            g.setColor(Color.red);
        g.setFont(new Font("Arial",Font.BOLD,25));
        g.drawString("Name="+tx1.getText(),250,380);

        g.setFont(new Font("Script",Font.BOLD,25));
        g.drawString("Password="+tx2.getText(),250,400);
        }


    }

    public void actionPerformed(ActionEvent ae)
    {

      String str=ae.getActionCommand();



      if(str=="Display")
      {
         a=1;

      }
      if(str=="Exit")
          {
              System.exit(0);
        }
        repaint();
    }
}
class echochar
{
    public static void main(String args[])
    {
        myframe f=new myframe();
        f.setVisible(true);
        f.setTitle("Calculate the Reverse");
        f.setSize(400,400);
    }
}


Friday, 14 June 2013

program in java for list demo in awt


import java.awt.*;
import java.awt.event.*;
class ListAction extends Frame
{
List list;
Label label;
    public ListAction()
    {
  
    // Set frame properties
    setTitle("List with ItemListener Demo");
    setSize(400,400);
    setLayout(new FlowLayout());
    setLocationRelativeTo(null);
    setVisible(true);
  
    // Create List
    list=new List();
  
    // Create label
    label=new Label();
  
    // Add items
    list.add("Apple");
    list.add("Mango");
    list.add("Guava");
    list.add("Orange");
    list.add("Pineapple");
    list.add("Grapes");
  
    // Add List
    add(list);
  
    // Add label
    add(label);
  
    // Add item listener
    list.addItemListener(new ItemListener(){
        public void itemStateChanged(ItemEvent ie)
        {
        label.setText("You selected "+list.getSelectedItem());
        }
    });
  
    }
    public static void main(String args[])
    {
    new ListAction();
    }
}

window listener demo , frame demo in java awt


import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements WindowListener
{
    public MyFrame()
    {
        setSize(500,500);
        setLocation(100,100);
        addWindowListener(this);
    }
    public void windowDeactivated(WindowEvent we)
    {
        System.out.println("Window is Deactivated");
    }
    public void windowActivated(WindowEvent we)
    {
        System.out.println("Window is Activated");
    }
    public void windowDeiconified(WindowEvent we)
    {
        System.out.println("Window is Deconified");
    }
    public void windowIconified(WindowEvent we)
    {
        System.out.println("Window is Iconified");
    }
    public void windowClosed(WindowEvent we)
    {
        System.out.println("Windos is closed");
    }
    public void windowClosing(WindowEvent we)
    {
        System.out.println("Window is closing");
        System.exit(0);
    }
    public void windowOpened(WindowEvent we)
    {
        System.out.println("Window is Opened");
    }
}
class FrameDemo
{
    public static void main(String []args)
    {
        new MyFrame().setVisible(true);       
    }
}

color font demo in java awt


/**
 * @(#)ColorFontDemo.java
 *
 *
 * @author - anant mahale 
 * @version 1.00 2013/3/18
 */
import java.awt.*;
import java.awt.event.*;
class ColorFont extends Frame implements ItemListener
{
    private Label lbl_msg;
    private Panel north_panel,south_panel,center_panel;
    private Choice ch_forecolor,ch_backcolor,ch_size;
    private Checkbox chb_bold,chb_italic,chb_plain;
    private CheckboxGroup cg=new CheckboxGroup();
    private int s;
    public ColorFont()
    {
        north_panel=new Panel();
        south_panel=new Panel();
        center_panel=new Panel();
       
        lbl_msg=new Label("Welcome to Java Programs");
       
       
        ch_forecolor=new Choice();
        ch_forecolor.add("Select Text Color");
        ch_forecolor.add("Red");
        ch_forecolor.add("Green");
        ch_forecolor.add("Blue");
       
        north_panel.add(ch_forecolor);
        ch_forecolor.addItemListener(this);
       
        ch_backcolor=new Choice();
        ch_backcolor.add("Select Back color");
        ch_backcolor.add("Red");
        ch_backcolor.add("green");
        ch_backcolor.add("blue");
       
        ch_backcolor.addItemListener(this);
        north_panel.add(ch_backcolor);
       
        ch_size=new Choice();
        ch_size.add("5");
        ch_size.add("10");
        ch_size.add("15");
        ch_size.add("20");
        ch_size.add("25");
        ch_size.add("30");
        ch_size.add("35");
        ch_size.addItemListener(this);
        add(north_panel,"North");
        add(south_panel,"South");
        add(center_panel);
       
        chb_bold=new Checkbox("Bold");
        chb_plain=new Checkbox("Plain",cg,true);
        chb_italic=new Checkbox("Italic",cg,false);
       
        chb_bold.addItemListener(this);
        chb_plain.addItemListener(this);
        chb_italic.addItemListener(this);
       
        south_panel.add(chb_bold);
        south_panel.add(chb_plain);
        south_panel.add(chb_italic);
        south_panel.add(ch_size);
        center_panel.add(lbl_msg);
        setTitle("ColorFont");
        setSize(500,500);
        setLocation(100,100);
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void itemStateChanged(ItemEvent ie)
    {
        if(ie.getSource()==ch_forecolor)
        {
            int i=ch_forecolor.getSelectedIndex();
            Color c=getColor(i);
            lbl_msg.setForeground(c);
        }
        else if(ie.getSource()==ch_backcolor)
        {
            int i=ch_backcolor.getSelectedIndex();
            Color c=getColor(i);
            north_panel.setBackground(c);
            south_panel.setBackground(c);
            center_panel.setBackground(c);
        }
        else if(ie.getSource()==ch_size)
        {
            String msg=ch_size.getSelectedItem();
            s=Integer.parseInt(msg);
            if(chb_bold.getState()&&chb_plain.getState())
                lbl_msg.setFont(new Font("ABC",Font.BOLD|Font.PLAIN,s));
            if(chb_bold.getState()&&chb_italic.getState())
                lbl_msg.setFont(new Font("ABC",Font.BOLD|Font.ITALIC,s));
            else
                lbl_msg.setFont(new Font("ABC",Font.ITALIC,s));
        }
        else if(ie.getSource()==chb_italic)
        {
            lbl_msg.setFont(new Font("ABC",Font.BOLD|Font.ITALIC,s));       
        }
        else if(ie.getSource()==chb_bold)
        {
            if(chb_bold.getState())
                lbl_msg.setFont(new Font("ABC",Font.BOLD,s));
            else
                lbl_msg.setFont(new Font("ABC",Font.PLAIN,s));           
        }
    }
    public static Color getColor(int i)
    {
        Color c=Color.white;
        switch(i)
        {
            case 1:c=Color.red;break;
            case 2:c=Color.green;break;
            case 3:c=Color.blue;break;
        }
        return c;
    }
}
class ColorFontDemo
{
    public static void main(String args[])
    {
        new ColorFont().setVisible(true);
    }
}

addition program in java awt


import java.awt.*;
import java.awt.event.*;
class add extends Frame implements ActionListener
{
    private TextField txt_fno,txt_sno,txt_sum;
    private Button btn_add;
    private Label lbl_fno,lbl_sno;
    public add()
    {
        setResizable(false);
        setTitle("Addition");
        setSize(300,300);
        setLocation(100,100);
        lbl_fno=new Label("Enter first number");
        lbl_sno=new Label("Enter Second Number");
        txt_fno=new TextField(10);
        txt_sno=new TextField(10);
        btn_add=new Button("Add");
        txt_sum=new TextField(10);
        setLayout(null);
        lbl_fno.setBounds(10,50,130,20);
        txt_fno.setBounds(150,50,100,20);
        lbl_sno.setBounds(10,100,130,20);
        txt_sno.setBounds(150,100,100,20);
        btn_add.setBounds(50,150,70,20);
        txt_sum.setBounds(150,150,100,20);
       
        add(lbl_fno);
        add(txt_fno);
        add(lbl_sno);
        add(txt_sno);
        add(btn_add);
        add(txt_sum);
        btn_add.addActionListener(this);
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_add)
        {
            int fno=Integer.parseInt(txt_fno.getText());
            int sno=Integer.parseInt(txt_sno.getText());
            int sum=fno+sno;
            txt_sum.setText(sum+"");
        }
    }
}
class AddDemo
{
    public static void main(String args[])
    {
        new add().setVisible(true);
    }
}

string replace in java awt



import java.awt.*;
import java.awt.event.*;
class StringWork extends Frame implements ActionListener
{
    private String str_msg1,str_msg2,str_replace,str_replacewith;
    private Button btn_change;
    private TextArea txta_show1,txta_show2;
    private Label lbl_replace,lbl_replacewith;
    private TextField txt_replace,txt_replacewith;
    public StringWork()
    {
        setLayout(null);
        setTitle("String Work");
        setSize(500,500);
        setLocation(100,100);
       
        txta_show1=new TextArea();
        txta_show1.setBounds(50,75,300,100);
        add(txta_show1);
       
        lbl_replace=new Label("Replace");
        lbl_replace.setBounds(50,225,100,30);
        add(lbl_replace);
       
        txt_replace=new TextField(20);
        txt_replace.setBounds(150,225,150,30);
        add(txt_replace);
       
        lbl_replacewith=new Label("ReplaceWith");
        lbl_replacewith.setBounds(50,260,100,30);
        add(lbl_replacewith);
       
        txt_replacewith=new TextField(20);
        txt_replacewith.setBounds(150,260,150,30);
        add(txt_replacewith);
       
        btn_change=new Button("Change");
        btn_change.setBounds(325,260,50,30);
        btn_change.addActionListener(this);
        add(btn_change);
       
   
       
        txta_show2=new TextArea();
        txta_show2.setBounds(50,350,300,100);
        add(txta_show2);
       
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_change)
        {
            str_replace=txt_replace.getText();
            str_replacewith=txt_replacewith.getText();
            str_msg1=txta_show1.getText();
             str_msg2 = str_msg1.replace(str_replace, str_replacewith);
            txta_show2.setText(""+str_msg2);
           
           
        }
    }
}
class StringWorkDemo
{
    public static void main(String args[])
    {
        new StringWork().setVisible(true);
    }
}

Application form in java awt


/**
 * @(#)SimpleFormDemo.java
 *
 *
 * @author - anant mahale
 * @version 1.00 2013/3/20
 */
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class SimpleForm extends Frame implements ItemListener,ActionListener
{
    private Label lbl_fname,lbl_lname,lbl_add,lbl_date,lbl_sex,lbl_games,lbl_e_mailid,lbl_aboutyou,lbl_at,lbl_com;
    private Button btn_submit,btn_clear,btn_close,btn_load;
    private TextField txt_fname,txt_lname,txt_e_mailid;
    private Choice ch_date,ch_month,ch_year,ch_email_site;
    private TextArea txta_result,txta_address,txta_aboutyou;
    private Checkbox chb_male,chb_female,chb_crickate,chb_football,chb_volleyball;
    private CheckboxGroup cg=new CheckboxGroup();
    private int birth_day,birth_month,birth_year;
    private String str_email="";
    public SimpleForm()
    {
        setBackground(Color.LIGHT_GRAY);
        setLayout(null);
        setTitle("Application Form");
        setSize(900,730);
        setLocation(0,0);
        setResizable(false); // cant change windows height and width

        lbl_fname=new Label("First Name");
        lbl_fname.setBounds(60,100,130,20);
        add(lbl_fname);

        lbl_lname=new Label("Last Name");
        lbl_lname.setBounds(60,150,130,20);
        add(lbl_lname);

        lbl_add=new Label("Address");
        lbl_add.setBounds(60,200,130,20);
        add(lbl_add);

        txt_fname=new TextField(10);
        txt_fname.setBounds(210,100,200,20);
        add(txt_fname);

        txt_lname=new TextField(10);
        txt_lname.setBounds(210,150,200,20);
        add(txt_lname);

        txta_address=new TextArea();
        txta_address.setBounds(210,200,200,100);
        add(txta_address);

        lbl_date=new Label("Date of Birth");
        lbl_date.setBounds(60,350,130,20);
        add(lbl_date);

        ch_date=new Choice();
        ch_date.add("1");
        ch_date.add("2");
        ch_date.add("3");
        ch_date.add("4");
        ch_date.add("5");
        ch_date.add("6");
        ch_date.add("7");
        ch_date.add("8");
        ch_date.add("9");
        ch_date.add("10");
        ch_date.add("11");
        ch_date.add("12");
        ch_date.add("13");
        ch_date.add("14");
        ch_date.add("15");
        ch_date.add("16");
        ch_date.add("17");
        ch_date.add("18");
        ch_date.add("19");
        ch_date.add("20");
        ch_date.add("21");
        ch_date.add("22");
        ch_date.add("23");
        ch_date.add("24");
        ch_date.add("25");
        ch_date.add("26");
        ch_date.add("27");
        ch_date.add("28");
        ch_date.add("29");
        ch_date.add("30");
        ch_date.add("31");
        ch_date.setBounds(200,350,0,20);
        ch_date.addItemListener(this);
        add(ch_date);

        ch_month=new Choice();
        ch_month.add("1");
        ch_month.add("2");
        ch_month.add("3");
        ch_month.add("4");
        ch_month.add("5");
        ch_month.add("6");
        ch_month.add("7");
        ch_month.add("8");
        ch_month.add("9");
        ch_month.add("10");
        ch_month.add("11");
        ch_month.add("12");
        ch_month.setBounds(250,350,0,20);
        ch_month.addItemListener(this);
        add(ch_month);

        ch_year=new Choice();
        ch_year.add("1985");
        ch_year.add("1986");
        ch_year.add("1987");
        ch_year.add("1988");
        ch_year.add("1989");
        ch_year.add("1990");
        ch_year.add("1991");
        ch_year.add("1992");
        ch_year.add("1993");
        ch_year.add("1994");
        ch_year.add("1995");
        ch_year.add("1996");
        ch_year.add("1997");
        ch_year.add("1998");
        ch_year.add("1999");
        ch_year.add("2000");
        ch_year.setBounds(300,350,0,20);
        ch_year.addItemListener(this);
        add(ch_year);

        lbl_sex=new Label("Sex");
        lbl_sex.setBounds(60,400,130,20);
        add(lbl_sex);

        chb_male=new Checkbox("Male",cg,true);
        chb_male.setBounds(200,400,100,20);
        chb_male.addItemListener(this);
        add(chb_male);

        chb_female=new Checkbox("Female",cg,false);
        chb_female.setBounds(300,400,100,20);
        chb_female.addItemListener(this);
        add(chb_female);

        lbl_games=new Label("Fev Games");
        lbl_games.setBounds(60,450,130,20);
        add(lbl_games);

        chb_crickate=new Checkbox("Crickate");
        chb_crickate.setBounds(210,450,75,20);
        chb_crickate.addItemListener(this);
        add(chb_crickate);

        chb_football=new Checkbox("FootBall");
        chb_football.setBounds(300,450,75,20);
        chb_football.addItemListener(this);
        add(chb_football);

        chb_volleyball=new Checkbox("VolleyBall");
        chb_volleyball.setBounds(390,450,75,20);
        chb_volleyball.addItemListener(this);
        add(chb_volleyball);

        lbl_e_mailid=new Label("E-mail-ID");
        lbl_e_mailid.setBounds(60,500,130,20);
        add(lbl_e_mailid);

        txt_e_mailid=new TextField(10);
        txt_e_mailid.setBounds(200,500,100,20);
        add(txt_e_mailid);
       
        lbl_at=new Label("@");
        lbl_at.setBounds(300,500,20,20);
        add(lbl_at);
       
               
        ch_email_site=new Choice();
        ch_email_site.add("gmail");
        ch_email_site.add("yahoo");
        ch_email_site.add("rediffmail");
        ch_email_site.add("hotmail");
        ch_email_site.setBounds(320,500,0,20);
        ch_email_site.addItemListener(this);
        add(ch_email_site);
       
        lbl_com=new Label(".com");
        lbl_com.setBounds(400,500,100,20);
        add(lbl_com);
       
        lbl_aboutyou=new Label("Something About You");
        lbl_aboutyou.setBounds(60,550,130,20);
        add(lbl_aboutyou);
       
        txta_aboutyou=new TextArea();
        txta_aboutyou.setBounds(200,550,200,100);
        add(txta_aboutyou);

        btn_clear=new Button("Clear");
        btn_clear.addActionListener(this);
        btn_clear.setBounds(225,700,100,20);
        add(btn_clear);

        btn_close=new Button("Close");
        btn_close.addActionListener(this);
        btn_close.setBounds(350,700,100,20);
        add(btn_close);

        btn_submit=new Button("Submit");
        btn_submit.addActionListener(this);
        btn_submit.setBounds(100,700,100,20);
        add(btn_submit);
       
        btn_load=new Button("Load Data");
        btn_load.addActionListener(this);
        btn_load.setBounds(650,700,100,20);
        add(btn_load);       

        txta_result=new TextArea();
        txta_result.setBounds(550,100,300,550);
        add(txta_result);       

        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
    public void paint(Graphics g)
    {
            g.setFont(new Font("Informal Roman",Font.BOLD,30));
            g.setColor(Color.black);
            g.drawString("Application Form",150,80);
           
            g.setFont(new Font("Informal Roman",Font.BOLD,30));
            g.setColor(Color.black);
            g.drawString("Data",660,80);
           
            g.drawLine(500,50,500,700);
            g.drawLine(505,50,505,700);
    }
    public void itemStateChanged(ItemEvent ie)
    {
        if(ie.getSource()==ch_date)
        {
            int i=ch_date.getSelectedIndex();
            switch(i)
            {
                case 0:birth_day=1;break;
                case 1:birth_day=2;break;
                case 2:birth_day=3;break;
                case 3:birth_day=4;break;
                case 4:birth_day=5;break;
                case 5:birth_day=6;break;
                case 6:birth_day=7;break;
                case 7:birth_day=8;break;
                case 8:birth_day=9;break;
                case 9:birth_day=10;break;
                case 10:birth_day=11;break;
                case 11:birth_day=12;break;
                case 12:birth_day=13;break;
                case 13:birth_day=14;break;
                case 14:birth_day=15;break;
                case 15:birth_day=16;break;
                case 16:birth_day=17;break;
                case 17:birth_day=18;break;
                case 18:birth_day=19;break;
                case 19:birth_day=20;break;
                case 20:birth_day=21;break;
                case 21:birth_day=22;break;
                case 22:birth_day=23;break;
                case 23:birth_day=24;break;
                case 24:birth_day=25;break;
                case 25:birth_day=26;break;
                case 26:birth_day=27;break;
                case 27:birth_day=28;break;
                case 28:birth_day=29;break;
                case 29:birth_day=30;break;
            }
        }
        if(ie.getSource()==ch_month)
        {
            int i=ch_month.getSelectedIndex();
            switch(i)
            {
                case 0:birth_month=1;break;
                case 1:birth_month=2;break;
                case 2:birth_month=3;break;
                case 3:birth_month=4;break;
                case 4:birth_month=5;break;
                case 5:birth_month=6;break;
                case 6:birth_month=7;break;
                case 7:birth_month=8;break;
                case 8:birth_month=9;break;
                case 9:birth_month=10;break;
                case 10:birth_month=11;break;
                case 11:birth_month=12;break;
            }
        }
        if(ie.getSource()==ch_year)
        {
            int i=ch_year.getSelectedIndex();
            switch(i)
            {
                case 0:birth_year=1985;break;
                case 1:birth_year=1986;break;
                case 2:birth_year=1987;break;
                case 3:birth_year=1988;break;
                case 4:birth_year=1989;break;
                case 5:birth_year=1990;break;
                case 6:birth_year=1991;break;
                case 7:birth_year=1992;break;
                case 8:birth_year=1993;break;
                case 9:birth_year=1994;break;
                case 10:birth_year=1995;break;
                case 11:birth_year=1996;break;
                case 12:birth_year=1997;break;
                case 13:birth_year=1998;break;
                case 14:birth_year=1999;break;
                case 15:birth_year=2000;break;
            }
        }
        if(ie.getSource()==ch_email_site)
        {
            int i=ch_email_site.getSelectedIndex();
            switch(i)
            {
                case 0:str_email="@gamil";break;
                case 1:str_email="@yahoo";break;
                case 3:str_email="@rediffmail";break;
                case 4:str_email="@hotmail";break;
            }           
        }
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_submit)
        {
            String str_sex="",str_game="";
            String str_fname,str_lname,str_e_mailid,str_add,str_fullname,str_upper_fullname,str_aboutyou;
            str_fname=txt_fname.getText();
            str_lname=txt_lname.getText();
            str_add=txta_address.getText();
            str_e_mailid=txt_e_mailid.getText();
            str_aboutyou=txta_aboutyou.getText();
           
            str_fullname=str_fname.concat(" "+str_lname);// string concatinate
            str_upper_fullname=str_fullname.toUpperCase();// convert string into uppercase            
           
            if(chb_male.getState())
            {
                str_sex="Male";
            }
            else if(chb_female.getState())
            {
                str_sex="Female";
            }
             if(chb_crickate.getState()&&chb_football.getState()&&chb_volleyball.getState())
            {
                str_game="Cricket, Football, Vallyball";
            }
            else if(chb_crickate.getState()&&chb_football.getState())
            {
                str_game="Cricket, Football";
            }
            else if(chb_crickate.getState()&&chb_volleyball.getState())
            {
                str_game="Cricket, Vallyball";
            }
            else if(chb_football.getState()&&chb_volleyball.getState())
            {
                str_game="Football, Vallyball";
            }
            else if(chb_crickate.getState())
            {
                str_game="Cricket";
            }
            else if(chb_football.getState())
            {
                str_game="Football";
            }
            else if(chb_volleyball.getState())
            {
                str_game="Cricket";
            }
            txta_result.setText("Name - "+str_upper_fullname+"\n\n"+"Address - "+str_add+"\n\n"+"Date Of Birth - "+birth_day+" | "+birth_month+" | "+birth_year+"\n\n"+"Sex - "+str_sex+"\n\n"+"Game - "+str_game+"\n\n"+"E-mailID - "+str_e_mailid+""+str_email+"\n\n"+"Something About You - "+str_aboutyou);
        }
        if(ae.getSource()==btn_clear)
        {
            txt_fname.setText(" ");
            txt_lname.setText(" ");
            txta_address.setText(" ");
            txt_e_mailid.setText(" ");   
        }
        if(ae.getSource()==btn_close)
        {
            new CloseDilog().setVisible(true);
        }
        if(ae.getSource()==btn_load)
        {
            try
            {
                FileDialog fd=new FileDialog(this,"Save File",FileDialog.SAVE);
                fd.setVisible(true);
                String txt=txta_result.getText();
                String dir=fd.getDirectory();
                String fname=fd.getFile();
                FileOutputStream fos=new FileOutputStream(dir+fname);
                DataOutputStream dos=new DataOutputStream(fos);
                dos.writeBytes(txt);
                dos.close();
            }
            catch(Exception e)
            {
            }
        }
    }
}
class CloseDilog extends  Dialog implements  ActionListener
{
    private Label lbl_msg;
    private Button btn_yes,btn_no;
    private Panel north_panel,south_panel;
    public CloseDilog()
    {
        super(new SimpleForm(),"Dialogbox for Close",true);
        north_panel=new Panel();
        south_panel=new Panel();
       
        setTitle("Confirm Close");
        setSize(200,200);
        setLocation(50,80);
        lbl_msg=new Label("Do you want to Close?");
        btn_yes=new Button("Yes");
        btn_no=new Button("No");
       
        north_panel.add(lbl_msg);
        south_panel.add(btn_yes);
        south_panel.add(btn_no);
        add(north_panel,"North");
        add(south_panel,"South");
        btn_yes.addActionListener(this);
        btn_no.addActionListener(this);
    }
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn_yes)
        {
            System.exit(0);
        }
        else
            dispose();
    }
}
class SimpleFormDemo
{
    public static void main(String []args)
    {
        new SimpleForm().setVisible(true);
    }
}