Layout Manager

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

There is no listener for the button's events. If there is no listener for a particular type of event, then the program ignores events of that type.

Layout Manager

Layout Artist

When you add() buttons (and other components) to a container, a layout manager automatically decides what size they will be and where they will go. This is convenient, because you can add components without worrying about the details. The layout manager is like a little artist inside the computer. You say what components you want and the layout manager lays them out in the picture.

The layout manager sometimes makes odd choices. However, there are several kinds of layout managers. Each layout manager has a different style of positioning components. Usually there is a layout manager that will do the job you want. If you don't specify otherwise, the container will use a default layout manager.

QUESTION 5:

Should the layout manager be specified before or after components are added to the frame?