Create a Frame with a button having caption PRESS ME, once the button is clicked, the caption changes to PRESSED.
PROGRAM :
package com.company;
import java.awt.*;
import java.awt.event.*;
public class Action1Frame extends Frame implements ActionListener
{
Button b1;
Action1Frame()
{
super(" I am A
Frame");
b1=new Button(" press
me");
add(b1);
b1.addActionListener(this);
setBounds(10,10,400,400);
setVisible(true);
}
public void
actionPerformed(ActionEvent ae)
{
if (ae.getSource()==b1)
b1.setLabel("PRESSED");
}
public static void
main(String[] args)
{
new Action1Frame();
}
}
/*
<applet code=Action1.class
width=400 height=400>
</applet>
*/
Labels: Create a Frame with a button having caption PRESS ME, once the button is clicked, the caption changes to PRESSED.


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home