Java Reference
In-Depth Information
{
JLabel myLabel =
new
JLabel("");
}
public void
paint( Graphics g)
{
super
.paint(g);
Container pane = g.getContentPane();
pane.setLayout(BORDER_LAYOUT);
pane.add(BORDER_LAYOUT.CENTER);
myLabel.setText("A Grand Welcome to "
+ "Java Programming! ");
}
}
1.
Create an applet to draw a digit using the method
fillRect
of the
class
Graphics
. For instance, if the input is 4, the applet will display the digit 4, as
shown in Figure 12-27.
FIGURE 12-27
Figure for Programming Exercise 1
2.
Modify the applet created in Programming Exercise 1 by adding eight radio
buttons so the user can change the color of the digit drawn.
Search WWH ::
Custom Search