import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code=prg12
height=500 width=500>
</applet>
*/
public class prg12 extends Applet implements ActionListener
{
Button b1;
Button b2;
Button b3;
public void init()
{
b1=new Button("Red");
b2=new Button("Blue");
b3=new Button("Green");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
add(b1);
add(b2);
add(b3);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
setBackground(Color.red);
}
else if(e.getSource()==b2)
{
setBackground(Color.blue);
}
else
{
setBackground(Color.green);
}
}
public void paint(Graphics g)
{
showStatus("Sanjay Chauhan");
}
}
import java.awt.*;
import java.awt.event.*;
/*
<applet code=prg12
height=500 width=500>
</applet>
*/
public class prg12 extends Applet implements ActionListener
{
Button b1;
Button b2;
Button b3;
public void init()
{
b1=new Button("Red");
b2=new Button("Blue");
b3=new Button("Green");
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
add(b1);
add(b2);
add(b3);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
setBackground(Color.red);
}
else if(e.getSource()==b2)
{
setBackground(Color.blue);
}
else
{
setBackground(Color.green);
}
}
public void paint(Graphics g)
{
showStatus("Sanjay Chauhan");
}
}
Background Color change click on button in java Applet
Reviewed by Unknown
on
6:14 pm
Rating:
No comments: