Write applet applets that display the current system time in different colors and fonts by receiving parameters in an HTML document.
Ex4_1.java
Import java.awt.*;
Import Java.applet.Applet;
Import Java.util.Calendar;
public class Ex4_1 extends applets
{
Calendar now;
Private String S1;
private int size,color;
public void init ()
{
now=calendar.getinstance (); Gets the system current time
S1=now.get (now. HOUR) + "Time"
+now.get (now. MINUTE) + "min"
+now.get (now. SECOND) + "seconds";
Size=integer.parseint (getparameter ("size"))//Get font size
color=integer.parseint (getparameter ("Color"), 16);// Gets the color value
} public
void Paint (Graphics g)
{color
c=new color (color);
G.setcolor (c);
Font f=new font ("", 1,size);
G.setfont (f);
g.DrawString (s1,10,50); Displays the string for the specified size color
}
Ex4_1.html
Run Effect chart:
A simple small program to do so, we can change according to their preferences font and color, I hope to learn Java programming help OH.