1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* Set Foreground Color Of an Applet Window Example This java example shows how to set foreground color of an Applet window using setForeground method of component class. */ /* <applet code="SetForegroundColorExample" width=200 height=200> </applet> */ import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class SetForegroundColorExample extends Applet{ public void paint(Graphics g){ /* * Set foreground color of an applet using * void setForeground(Color c) method. */ setForeground(Color.red); g.drawString("Foreground color set to red", 50, 50); } } |
Example Output
Add Comment