Friday 14 June 2013

program in java - simple button program in awt


import java.awt.*;
class MyFrame extends Frame
{
    private Button btn_east,btn_west,btn_south,btn_norht,btn_center;
    public MyFrame()
    {
        setTitle("My First Button Program");
        setSize(400,400);
        setResizable(false);
        setLocation(100,100);
        btn_east=new Button("East");
        btn_west=new Button("West");
        btn_norht=new Button("North");
        btn_south=new Button("South");
        btn_center=new Button("Center");
        add(btn_east,"East");
        add(btn_west,"West");
        add(btn_norht,"North");
        add(btn_south,"South");
        add(btn_center,"Center");
    }
}
class FirstButton
{
    public static void main(String []args)
    {
        new MyFrame().setVisible(true);
    }
}

No comments: