How to create color changer mini-project using java applet with source code


https://www.myprogrammingschool.com/search/label/Project
color changer
 

How to create color changer mini-project using java applet with source code

Source Code

 
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.Color;
class ColourChange extends Applet implements ActionListener
{
Frame f;
/* public void init()
{
f.setbackground(Color.pink);
}
*/
 
Button b1,b2,b3;
ColourChange()
{
f=new Frame(“Colour”);
 
b1=new Button(“red”);
b2=new Button(“yellow”);
b3=new Button(“green”);
 
f.setVisible(true);
f.setSize(400,400);
f.setLayout(new FlowLayout());
f.setBackground(Color.black);
 
f.add(b1);
f.add(b2);
f.add(b3);
 
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public void actionPerformed(ActionEvent  e)
{
if(e.getSource().equals(b1))
{
f.setBackground(Color.red);
}
if(e.getSource().equals(b2))
{
f.setBackground(Color.yellow);
}
 if(e.getSource().equals(b3))
{
f.setBackground(Color.green);
}
}
public static void main(String…aa)
{
new ColourChange();
}
}
For more Project
 

How to create color changer mini-project using java applet with source code

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Domain & free Hosting

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.