Java Reference
In-Depth Information
EXAMPLE 12-4
//GrandWelcomeLine Applet
import java.awt.*;
import javax.swing.JApplet;
public class GrandWelcomeLine extends JApplet
{
public void paint( Graphics g)
{
super .paint(g);
g.setColor(Color.red);
g.setFont( new Font("Courier", Font.BOLD, 24));
g.drawString("Welcome to Java Programming", 30, 30);
g.drawLine(10, 10, 10, 40);
//left line
g.drawLine(10, 40, 430, 40);
//bottom line
g.drawLine(430, 40, 430, 10);
//right line
g.drawLine(430, 10, 10, 10);
//top line
}
}
The HTML file for this program contains the following code:
<HTML>
<HEAD>
<TITLE>WELCOME</TITLE>
</HEAD>
<BODY>
<OBJECT code = "GrandWelcomeLine.class" width = "440"
height = "50">
</OBJECT>
</BODY>
</HTML>
Sample Run: Figure 12-7 shows the output of the GrandWelcomeLine applet.
1
2
FIGURE 12-7 Output of the GrandWelcomeLine applet
 
Search WWH ::




Custom Search