Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

Pgm 7 || section B || Create a frame which displays your personal details with respect to a button click

 import java.awt.*;

import java.awt.event.*;

public class Pgm7 implements ActionListener

{

Label info;

Button b1,b2;

Pgm7()

{

Frame f=new Frame("ActionListener Example");

info=new Label();

info.setBounds(5,50, 400,50);

b1=new Button("Display Info");

b2=new Button("Exit");


b1.setBounds(50,100,100,30);

b2.setBounds(170,100,60,30);


b1.addActionListener(this);

b2.addActionListener(this);


f.add(b1);

f.add(b2);


f.add(info);

f.setSize(400,400);

f.setLayout(null);

f.setVisible(true);

}


public void actionPerformed(ActionEvent e)

{

if (e.getSource() == b1)

{

info.setText("ABCD,Belgaum,9876543221,Height:5.6,Wieght:50,Gender:Mal

e ");

}


if (e.getSource() == b2)

{

System.exit(0);

}

}

public static void main(String[] args)

{

new Pgm7();

}

}

Post a Comment

0 Comments