Wednesday, December 21, 2011

Get Foreground Color Of an Applet Window

package org.best.example;

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

No comments: