Size of the Frame

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:

See the buttons.

Size of the Frame

The layout manager for this GUI is FlowLayout, which means that the components are placed in the Frame left to right in rows starting at the top. As many components as can fit go into the first row, even if this means separating a label from its button:

wide frame

To get the GUI to look right, the width and height have to be set correctly:

fatApp.setSize( 280, 200 );     

This is a matter of trial-and-error. There are better ways to do this using features of Swing discussed in the following chapters. Another useful thing to do is to give the entire frame a title. This is done with:

setTitle( String title )

Now the top bar of the frame (the one that contains the "close button") has this title. In previous examples this was done by calling the superclass constructor with the title string.

QUESTION 16:

Suggest a good title for the frame.