Java Reference
In-Depth Information
red = ( float ) Math.random();
green = ( float ) Math.random();
blue = ( float ) Math.random();
bottomrightJL.setForeground( new Color(red, green, blue));
c.add(topleftJL);
c.add(toprightJL);
c.add(bottomleftJL);
c.add(bottomrightJL);
}
}
The HTML file that invokes this applet contains the following code:
<HTML>
<HEAD>
<TITLE>Four Colors</TITLE>
</HEAD>
<BODY>
<OBJECT code = "ColorsDisplayed.class" width = "400"
height = "200">
</OBJECT>
</BODY>
</HTML>
Sample Run: Figure 12-4 shows the output of the ColorsDisplayed applet.
FIGURE 12-4 Output of the ColorsDisplayed applet
You can use both the class Font and the class Color to enhance your presentation of
an applet. For example, consider the GrandWelcome applet given in Example 12-3,
which shows the complete program listing followed by a sample run.
 
Search WWH ::




Custom Search