esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

How do I change the Applet background color to the HTML background color?

The applet background is adapted to the HTML background color. It is passed to the applet by an initial parameter.

Clicking the button will call a Javascript function that will call the Applet's method "newBackground(String color)" so that it dynamically adapt the backgound.







In order to achieve the same background color of the applet and the HTML page, the HTML background color should be passed to the applet at initialization time.

This can be done by an applet parameter at the HTML side, and by calling the getParameter(String par) method at the applet side, i.e. within the init() method and a further call to i.e. newBackground(String color) will perform the color change.

In case of dynamic HTML pages, where the background color dynamically changes, the newBackground(String color) method should directly be called each time the HTML background changes. In this example we call it from the JavaScript function setColor() directly.

Inside your HTML page:

This code sample is only viewable to esus.com members
Login or become a member!



AppletTransparentDemo.java:

This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Sandor Gyarmati

Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.