File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes cant change background color of applet with button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "cant change background color of applet with button click" Watch "cant change background color of applet with button click" New topic
Author

cant change background color of applet with button click

Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
I am working on an assignment to create an applet where I need to change the background color of the applet with some button clicks


I am not getting any errors in eclipse so far, here is my code:



I appreciate the help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
You haven't added the applet as an action listener to the 3 buttons, hence the actionPerformed method is never called.
Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
so would that be something like this?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
You shouldn't create a new instance of the applet class; it'd be like:

red.addActionListener(this);
green.addActionListener(this);
 
Consider Paul's rocket mass heater.
 
subject: cant change background color of applet with button click