CHAPTER 62 — JPanel and BoxLayout

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 home page   go to next page

created: 01/12/02; revised: 07/18/06 ; refurbished 11/09/08

CHAPTER 62 — JPanel and BoxLayout

The graphical interfaces of the previous chapters have a problem: when the user resizes the frame the layout of components can change drastically. FlowLayout does not keep related items together. It just puts them in the rows one after another as they are added. A label and the component it labels may end up in different rows. This chapter discusses how to better control the layout process.

Chapter Topics:

  • The setResizable() method
  • Arranging components in a JPanel
  • Nested JPanels
  • The BoxLayout layout manager

QUESTION 1:

(Review: ) Has the user been able to resize the frame of the GUIs in the previous chapters?