Class 1, Part 2 |
Intro to Java 30-IT-396 |
|
Layout Management
-
Unlike many programming languages, we generally don't specify absolute
positions when laying out components in Java.
-
Why not? Keep in mind, people set their screens to different resolutions.
And different operating systems use different resolutions as well.
Java is designed to run in different environments. If you specify hard
positions for each of your components, it will not look good when resized
or when used on a computer with a different resolution than yours!
Trust me here...
-
So, the solution is the concept of layout managers.
-
Layout managers dynamically position components in your Frame. If
the size of your frame changes, or the resolution is different, layout
managers automatically reposition your components.
-
But this flexibility comes at a price. You have to figure out what
layout managers to use.
-
The trick is to nest the layout managers.
-
A frame can have one layout manager. Then, within that layout, you
can place panels.
-
Each panel can have a layout manager. Within those panels, you can
have even more panels with even more layout managers.
-
So, let's take a look at an example.
An example



Created by: Brandan
Jones January 4, 2002