Get Background Color Of an Applet Window Example
- /*
- Get Background Color Of an Applet Window Example
- This java example shows how to get background color of an Applet window using
- getBackground method of component class.
- */
- /*
- <applet code="GetBackGroundColorExample" width=200 height=200>
- </applet>
- */
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Graphics;
- public class GetBackGroundColorExample extends Applet{
- public void paint(Graphics g){
- //get background color using getBackground method
- Color c = getBackground();
- g.drawString(c.toString(),50,50);
- }
- }
Example Output




