Work on Your Swing — Chapter 13

The three layout managers

  1. borderlayout — A BorderLayout manager divides a background component into five r~ions. You canadd only one component per region to a background controlled by a BorderLayout manager. Components laid out by this manager usually don’t get to have their preferred size. 9orderlayout Is the default layout II\Qna~ for Q fromel
  2. flow — A FlowLayout manager acts kind of like a word processor, except with components instead of words. Each component is the size it wants to be, and they’re laid out left to right in the order that they’re added. with ·word-wrap” turned on. So when a component won’t tit horizontally, it drops to the next “line” in the layout. FlowLayout Is the default layout mo~,. for a pone”
  3. box — A BoxLayout manager is like FlowLayout in that each component gets to have its own size, and the components are placed in the order in which they’re added. But. unlike FlowLayout. a BoxLayout manager can stack the components vertically (or horizontally, but usually we’re just concerned with vertically). It’s like a FlowLayout but instead of having automatic ‘component wrapping’, you can insert a Sort of ‘component return key’ and force the components to start a new line. -

Few facts about Swing

  1. Layout managers control the size and location of components nested within other components.
  2. When you add a component to another component (sometimes referred as a background component, the added component is controlled by the layout manager of the background component
  3. A layout manager asks components for their preferred size, before making a decision about the layout. Depending on the layout manager’s policies, it might respect all, some, or none of the component’s wishes.
  4. The BorderLayout manager lets you add a component to one of the five regions. You must specify the region when you add the component, using the following syntax:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Upulie Handalage

Upulie Handalage

Everything in my point of view. Here for you to read on....