Start of Tutorial > Start of Trail |
Search
Examples Index |
This lesson tells you how to use layout managers that the Java platform provides. It also tells you how to use absolute positioning (no layout manager) and gives an example of writing a custom layout manager. For each layout manager (or lack thereof), this section has an example that can run either as an applet or as an application. By resizing the window the example brings up, you can see how size changes affect the layout.Before reading this section, you should understand basic layout management concepts, which you can find in Layout Management.
Note: This lesson assumes you're using the Swing components. If you're using the AWT components instead, then you should read the old version of this lesson, which is available by download as part of the Creating a User Interface (AWT Only) archive.
This section gives both general rules and detailed instructions on using each of the layout managers that the Java platform provides.
Instead of using one of the Java platform's layout managers, you can write your own. Layout managers must implement theLayoutManager
interface, which specifies the five methods every layout manager must define. Optionally, layout managers can implementLayoutManager2
, which is a subinterface ofLayoutManager
.
If necessary, you can position components without using a layout manager. Generally, this solution is used to specify absolute sizes and positions for components.
Some of the most common layout problems are that components are displayed too small -- or not at all. This section tells you how to fix these and other common layout problems.
Start of Tutorial > Start of Trail |
Search
Examples Index |