Layout managers ||Object Oriented Programming Spring2016

Layout Manager

 Layout Managers

A layout manager is an entity that administers the layout manager interface and regulates the size and position of the elements within a container. Even though the elements can supply size and alignment hints, a container’s layout manager has the ultimate say on the size and position of the elements within the container.

There are around 8 layout managers in Java. Any two layout managers that are available in Java are mentioned below.

  • Flow Layout
  • Border Layout

 

The above-mentioned layout managers are explained below:

  • Flow Layout

A flow layout is a type of layout manager that exhibits elements in a left-to-right flow. It is much like the lines of text in a paragraph. Flow layouts are generally used to organize or arrange buttons in a panel. It will schedule buttons left-to-right until no more buttons fit on the same line.

 

  • Border Layout

A border layout is a type of layout manager which is the default layout for the window entity such as JFrame, JWindow, JDialog, JInternalFrame, etc. Border Layout organizes the elements in the five regions (north, south, east, west, and middle part(center). Each region can hold or carry only one element.

 

Swing and AWT are differentiated below:

Swing AWT
·     Swing is a GUI widget toolkit for Java that is an extension of AWT. ·     AWT is Java’s platform-dependent windowing, graphics, and user interface widget toolkit.
·     Swings in java are a lightweight element. ·     AWT in java is called heavyweight element.
·     They are platform-independent. ·     They are platform-dependent.
·     In Java, Swing has them built-in. ·     In Java, User has to implement a lot of things themselves.
·     Swing elements require javax.swing package. ·     AWT elements require java.awt package.

 

You may also like Types of Inheritance in java with suitable example spring 2016||Object Oriented Programming

Be the first to comment

Leave a Reply

Your email address will not be published.


*