BorderLayout

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:

BorderLayout

Border Layout

BorderLayout.is a frequently used layout manager. The container it manages corresponds to a rectangle on the screen. That rectangle is divided up into five regions:

  • BorderLayout.NORTH,
  • BorderLayout.SOUTH,
  • BorderLayout.EAST,
  • BorderLayout.WEST,
  • BorderLayout.CENTER.

Each region may hold only one component, although that component may be a panel (and usually is). The panel may contain several components. The layout manager adjusts the size of the regions depending on what is in them. You don't have to put a component in each region. If a region has no component in it, it shrinks to a small area.

QUESTION 7:

Add to its frame the three panels from the ideal weight application, genderPanel, heightPanel, resultPanel.

// Add Panels to the Frame
setLayout( new BorderLayout() );
add( genderPanel, BorderLayout. );
add( heightPanel, BorderLayout. );
add( resultPanel, BorderLayout. );