Sunday, December 25, 2011

Set Background Color Of an Applet Window

package org.best.example;

    /*
            Set Background Color Of an Applet Window Example
            This java example shows how to set background color of an Applet window using
            setBackground method of component class.
    */
    
    /*
    <applet code="SetBackgroundColorExample" width=200 height=200>
    </applet>
    */
    
    
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    
    public class SetBackgroundColorExample extends Applet{
    
            public void paint(Graphics g){
                    /*
                     * Set background color of an applet using
                     * void setBackground(Color c) method.
                     */
                  
                    setBackground(Color.red);
            }
    }

No comments: