Untitled
unknown
plain_text
2 years ago
1.4 kB
9
Indexable
Frame f=new Frame("Button Event");
Label l=new Label("DETAILS OF PARENTS");
l.setFont(new Font("Calibri",Font.BOLD, 16));
Label nl=new Label();
Label dl=new Label();
Label al=new Label();
l.setBounds(20,20,500,50);
nl.setBounds(20,110,500,30);
dl.setBounds(20,150,500,30);
al.setBounds(20,190,500,30);
Button mb=new Button("Mother");
mb.setBounds(20,70,50,30);
mb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
nl.setText("NAME:"+" "+"Aishwarya");
dl.setText("DESIGNATION:"+" "+"Professor");
al.setText("AGE:"+" "+"42");
}
});
Button fb=new Button("Father");
fb.setBounds(80,70,50,30);
fb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
nl.setText("NAME:"+" "+"Ram");
dl.setText("DESIGNATION:"+" "+"Manager");
al.setText("AGE:"+" "+"44");
}
});
//adding elements to the frame
f.add(mb);
f.add(fb);
f.add(l);
f.add(nl);
f.add(dl);
f.add(al);
// setting size,layout, and visibility
f.setSize(250,250);
f.setLayout(null);
f.setVisible(true);
}
}Editor is loading...