Java Reference
In-Depth Information
Figure 2.3 Result of the program
SimpleFrameDriver
to position (300
300) in Line 10. Both frames are empty, i.e. there is nothing in
their content panes.
,
File:
its/SimpleFrame/SimpleFrameDriver.java
1.
package
its.SimpleFrame;
2.
3.
public class
SimpleFrameDriver
4.
{
5.
public static void
main(String[] args)
6.
{
7.
SimpleFrame sFrame1 =
new
SimpleFrame();
8.
SimpleFrame sFrame2 =
new
SimpleFrame();
9.
sFrame1.showIt("SimpleFrame 1");
10.
sFrame2.showIt("SimpleFrame 2",300,300);
11.
}
12.
}
The result should look like Figure 2.3. This picture is taken under WindowsXP; it
might appear slightly different on other platforms. As mentioned above, the frame
can be resized and moved with the mouse. These basic functions are automatically
!
supplied.
2.2
■
Panels and layouts
We will now embed other graphical components into a frame. The components
used are called
panels
. These are rectangular components, which serve two main
Search WWH ::
Custom Search