A simple frame design with event model
import java.awt.*;
import java.awt.event.*;
class eventmodeling extends Frame implements ActionListener
{
Button b;
TextField t;
eventmodeling()
{
b=new Button(“Click Here and Get it Displayed”);
t=new TextField(30);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(t);
add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String s=e.getActionCommand();
if(s.equals(“Click Here and Get it Displayed”))
t.setText(“Haha!!! Displayed”);
}
public static void main(String args[])
{
eventmodeling z=new eventmodeling();
z.setSize(300,300);
z.setVisible(true);
}
}
Leave a Comment