Borderless Frame pack()

Borderless Frame pack()

Borderless Frame pack()

Summary: By the end of this tutorial "Borderless Frame pack()", you will understand how to create a borderless frame and pack() method.

1. Creating a borderless window

Frame is known as top-level window as it contains border and title bar (panel is not a top-level window; it is always a child window and does not have existence without a top-level window). A frame can be created without a border but of little practical use.

Borderless Frame pack()

Output screen of of Borderless Frame pack()

Window is the super class of Frame (see the container hierarchy). Frame is added to window. Button is added to window and window is added to monitor. Window gives a generic window. Observe, the class does not extend Frame.

2. Packing the Components with pack()

If you would like to have the frame in it's preferred size (with all embedded components), just give pack() instead of setSize() method. The following program explains.

Borderless Frame pack()
pack() method displays a frame just sufficient to display the components and the three icons (minimize, maximize, close) on the title bar. The frame can be resized by dragging on the borders. This style without border is not used in regular practice.

===================Extra Reading=============================

To add more features to AWT components: Advanced AWT (Swing Components)

Leave a Reply

Your email address will not be published. Required fields are marked *