Java Reference
In-Depth Information
Given:
import java.awt.*;
import javax.swing.*;
public class Result extends JFrame {
public Result() {
super(“Result”);
JLabel width = new JLabel(“This frame is “ +
getSize().width + “ pixels wide.”);
add(“North”, width);
setSize(220, 120);
}
public static void main(String[] arguments) {
Result r = new Result();
r.setVisible(true);
}
}
What will be the reported width of the frame, in pixels, when the application runs?
a.
0 pixels
b.
120 pixels
c.
220 pixels
d.
The width of the user's monitor
The answer is available on the topic's website at
http://www.java21days.com.
Visit the
Day 13 page and click the Certification Practice link.
To extend your knowledge of the subjects covered today, try the following exercises:
1.
Create an application that draws a circle with its radius, x,y position, and color all
determined by parameters.
2.
Create an application that draws a pie graph.
Where applicable, exercise solutions are offered on the topic's website at
http://www.