SlideShare a Scribd company logo
Layout Manager
 FlowLayout
 BorderLayout
 CardLayout
 GridLayout
 GridBagLayout with
 GridBagConstraints
 Intro. to BoxLayout, SprigLayout,GroupLayout
 Using NO LAYOUT Manager
Layout Manager
 The layout manager decides how the
controls should be arranged or positioned
within a container or a window.
 In java there is no such form designer, but
you have to write the code to arrange the
controls where you want them.
 A layout manager is an object of a class the
implements the LayoutManager interface.
 To set the layout following method is used:
 Void setLayout(LayoutManager obj)
 The obj is an object of the specified
layout manager.
 If no layout manager is set by setLayout()
method, the default layout manager is
used which is the FlowLayout.
FlowLayout Class
 The FlowLayout is the default layout manager.
 If no layout manager is set by the setLayout()
method, this layout is used to arrange the
controls in a container.
 In FlowLayout manager, the components are
arranged the from the upper-left corner to the
right side edge of the container.
 When there is no space for the component, it is
arranged from the next line.
 A little space is added between each component
at all of the four sides.
Constructors
 FlowLayout()
 FlowLayout(int align)
 FlowLayout(int align,hspace, vspace)
 Alignment can be done by following
 FlowLayout.CENTER //is default
 FlowLayout.LEFT
 FlowLayout.RIGHT
 Hspace and vspace is the horizontal and vertical
spaces between the components.
 The default space is 5 pixels from both horizontal and
vertical.
Methods of FlowLayout
 public int getAlignment()
 Gets the alignment for this layout.
 Possible values are FlowLayout.LEFT,
FlowLayout.RIGHT,FlowLayout.CENTER,
 Returns: the alignment value for this layout.
 public void setAlignment(int align)
 Sets the alignment for this layout. Possible values are
 FlowLayout.LEFT
 FlowLayout.RIGHT
 FlowLayout.CENTER
 Parameters: align - one of the alignment values shown above
 public int getHgap()
 Gets the horizontal gap between components and
between the components and the borders of the
Container
 public void setHgap(int hgap)
 Sets the horizontal gap between components and
between the components and the borders of the
Container.
 public int getVgap()
 Gets the vertical gap between components and between
the components and the borders of the Container.
 public void setVgap(int vgap)
 Sets the vertical gap between components and between
the components and the borders of the Container.
 Demo of FlowLayout Class
BorderLayout class
 A border layout lays out a container, arranging
and resizing its components to fit in five regions:
north, south, east, west, and center.
 Each region may contain more than one
component, and is identified by a corresponding
constant: NORTH, SOUTH, EAST, WEST, and
CENTER.
 When adding a component to a container with a
border layout, use one of these five constants.
Constructors
 public BorderLayout()
 Constructs a new border layout with no gaps between
components.
 public BorderLayout(int hgap,int vgap)
 Constructs a border layout with the specified gaps between
components. The horizontal gap is specified by hgap and the
vertical gap is specified by vgap.
 hgap - the horizontal gap.
 vgap - the vertical gap.
 BorderLayout defines the following constants that
specify the regions:
 BorderLayout.CENTER
 BorderLayout.SOUTH
 BorderLayout.EAST
 BorderLayout.WEST
 BorderLayout.NORTH
 When adding components, you will use these
constants with the following form of add( ),
which is defined by Container:
 void add(Component compObj, Object region)
 Here, compObj is the component to be added, and
region specifies where the componentwill be added.
Methods of BorderLayout
 public int getHgap()
 Returns the horizontal gap between components
 public void setHgap(int hgap)
 Sets the horizontal gap between components.
 public int getVgap()
 Returns the vertical gap between components.
 public void setVgap(int vgap)
 Sets the vertical gap between components.
 Demo of BorderLayout Class
CardLayout
 The card layout has some special capabilities
that other layout don’t have.
 The card layout creates a layout like the playing
the cards.
 Assume more than one card on one another.
Here, only the card on the top is visible at a
time, but you shuffle the cards to see other
hands.
 Same way, the CardLayout can switch among
several panels.
 The cards are typically held in an object of type Panel.
This panel must have CardLayout selected as its
layout manager.
 The cards that form the deck are also typically objects
of type Panel.
 Thus, you must create a panel that contains the
deck and a panel for each card in the deck.
 Next, you add to the appropriate panel the components
that form each card.
 You then add these panels to the panel for which
CardLayout is the layout manager.
 Finally, you add this panel to the main applet panel.
Once these steps are complete, you must provide
some way for the user to select between cards.
 One common approach is to include one push button
for each card in the deck.
 When card panels are added to a panel, they are
usually given a name.
 Thus, most of the time, you will use this form of add( )
when adding cards to a panel:
 void add (Component panelObj, Object name);
 Here, name is a string that specifies the name of the card
whose panel is specified by panelObj.
Constructors
 public CardLayout()
 Creates a new card layout with gaps of size zero.
 public CardLayout (int hgap,int vgap)
 Creates a new card layout with the specified
horizontal and vertical gaps.
 The horizontal gaps are placed at the left and right
edges.
 The vertical gaps are placed at the top and bottom
edges.
 Parameters:
 hgap - the horizontal gap.
 vgap - the vertical gap.
Methods of CardLayout
 public void first (Container parent)
 Flips to the first card of the container.
 public void next (Container parent)
 Flips to the next card of the specified container. If the currently
visible card is the last one, this method flips to the first card in
the layout.
 public void previous (Container parent)
 Flips to the previous card of the specified container. If the
currently visible card is the first one, this method flips to the last
card in the layout.
 public void last (Container parent)
 Flips to the last card of the container.
 public void show (Container parent,String name)
 Flips to the component that was added to this layout with the
specified name, using addLayoutComponent. If no such
component exists, then nothing happens.
 public int getHgap()
 Gets the horizontal gap between components.
 Returns: the horizontal gap between components.
 public void setHgap(int hgap)
 Sets the horizontal gap between components.
 Parameters: hgap - the horizontal gap between components.
 public int getVgap()
 Gets the vertical gap between components.
 Returns: the vertical gap between components.
 public void setVgap(int vgap)
 Sets the vertical gap between components.
 Parameters: vgap - the vertical gap between components.
 Demo of CardLayout using JFrame
 Demo of CardLayout using Panel
 Demo of CardLayout using Panel
GridLayout
 The GridLayout class creates a layout which has
a grid of rows and columns.
 The GridLayout class is a layout manager that
lays out a container's components in a
rectangular grid.
 The container is divided into equal-sized
rectangles, and one component is placed in
each rectangle.
Constructors
 public GridLayout()
 Creates a grid layout with a default of one column per component, in a
single row.
 public GridLayout (int rows,int cols)
 Creates a grid layout with the specified number of rows and columns.
All components in the layout are given equal size.
 One, but not both, of rows and cols can be zero, which means that any
number of objects can be placed in a row or in a column.
 public GridLayout (int rows,int cols,int hgap,int vgap)
 Creates a grid layout with the specified number of rows and columns.
All components in the layout are given equal size.
 rows - the rows, with the value zero meaning any number of rows
 cols - the columns, with the value zero meaning any number of
columns
 hgap - the horizontal gap
 vgap - the vertical gap
Methods
 public int getRows()
 Gets the number of rows in this layout.
 public void setRows (int rows)
 Sets the number of rows in this layout to the specified value.
 public int getColumns()
 Gets the number of columns in this layout.
 public void setColumns (int cols)
 Sets the number of columns in this layout to the specified value.
 public int getHgap()
 Gets the horizontal gap between components.
 public void setHgap (int hgap)
 Sets the horizontal gap between components to the specified value.
 - public int getVgap ()
 Gets the vertical gap between components.
 public void setVgap (int vgap)
 Sets the vertical gap between components to the specified value.
 Demo of GridLayout with JFrame
 Demo of GridLayout with JApplet
GridBagLayout
 The GridBagLayout is very flexible layout manager.
 It is an extension of GridLayout that provides some
more features than the GridLayout.
 In the GridLayout all the cells have same height
and width which is not necessary in the
GridBagLayout.
 Here, you can have cells of arbitrary width and
height.
 This can be done by specifying constraints.
 To specify constraints you have to create an
object of GridBagConstrains.
 Position, size, and properties of components
are determined by setting the
GridBagConstraints of the GridBagLayout to
particular values before the component is
added to the container.
 GridBagConstraints specify:
1. Location and size of the component on the
grid.
2. Position and size of the component within the
rectangular region specified in 1.
3. Behavior of the component and its region
when the container is resized.
Steps for Using a GridBag
1. Create a GridBagLayout object, say gbl, and set it to
be the layout manager of the Container.
 GridBagLayout gbl = new GridBagLayout();
 setLayout(gbl);
2. Create a GridBagConstraints object, say gbc, and
provide values for its public instance variables for
each Component, in turn, to be placed on the
Container.
 GridBagConstraints gbc = new GridBagConstraints();
3. Place component using
 gbl.setConstraints (component, gbc);
 add(component);
 or
 add(component, gbc);
Instance variables that you can set to
GridBagConstraints
 gridx and gridy
 girdx specifies the horizontal position and gridy
specifies the vertical position of the component.
 The left most components have the gridx=0 and the
upper most components have the gridy=0.
 The default value is GridBagConstraints.RELATIVE
which places the components just right to the
previously added component for gridx and just
below to the previously added component for
gridy.
 gridwidth and gridheight
 The gridwidth specify the width and gridheight
specifies height of the cell in number of rows and
number of columns respectively.
 The height and width is in number of cells and not
in pixels.
 The default value is 1 for both.
 fill
 It specifies what to do Its valid values are:if the
component’s size is larger than the size of the
cell.
 GridBagConstraints.NONE: default value
 GridBagConstraints.HORIZONTAL
 it changes the width of the component to fit in the
cell. It does not change the height of the
component.
 GridBagConstraints.VERTICAL
 it changes the height of the component to fit in the
cell. It does not change the width of the
component.
 GridBagConstraints.BOTH
 it changes both height and width of the
component to fit in the cell.
 ipadx and ipady
 They specifies the internal padding of the component
means it specifies that how many space will
remain around the component in the cell.
 the ipadx specifies the horizontal space and the ipady
specifies the vertical space in pixels.
 The default value is 0 for both.
 weightx and weighty
 The weightx and weighty specify the horizontal and
vertical space between the edge of the container and
the cells respectively.
 The default value is 0.0
 int anchor
 Tells where the component is positioned in its
allocated region, one of CENTER, NORTH,
EAST, SOUTH, WEST, NORTHEAST,
SOUTHEAST, SOUTHWEST, or
NORTHWEST.
 Default: CENTER
 Demo of GridBagLayout
BoxLayout
 The BoxLayout is a general purpose layout manager
which is an extension of FlowLayout.
 It places the components on top of each other or places
them one after another in a row.
 Constructor
 public BoxLayout(Container obj, int axis)
 Creates a layout manager that will lay out components
along the given axis.
 obj – is the object of a container such as panel.
 axis - the axis to lay out components along.
 BoxLayout.X_AXIS,
 BoxLayout.Y_AXIS,
 BoxLayout.LINE_AXIS or
 BoxLayout.PAGE_AXIS
 There are four axis:
 public static final int X_AXIS
 Specifies that components should be laid out left to
right.
 public static final int Y_AXIS
 Specifies that components should be laid out top to
bottom.
 public static final int LINE_AXIS
 it places the components in a line, one after another
 public static final int PAGE_AXIS
 It places the components like stack. On the top of
each other.
 Demo of BoxLayout
Spring Layout
 The Spring Layout is a very flexible layout
that has many features for specifying the
size of the components.
 You can have different size rows and/or
columns in a container.
 In Spring Layout you can define a fixed
distance between the left edge of one
component and right edge of another
component.
 public SpringLayout()
 Constructs a new SpringLayout.
 void putConstraint (string edge1,component
obj1,int distance, string edge2 ,component
obj2)
 void putConstraint (string edge1,component
obj1,spring distance, string edge2
,component obj2)
 In this edge value can be one of the following:
 SpringLayout.NORTH
 SpringLayout.EAST
 SpringLayout.WEST
 SpringLayout.SOUTH
 Demo of SpringLayout
Group Layout
 GroupLayout is a LayoutManager that hierarchically
groups components in order to position them in a
Container.
 Grouping is done by instances of the Group class.
 GroupLayout uses two types of arrangements –
sequential and parallel, combined with hierarchical
composition.
 With sequential arrangement, the components are
simply placed one after another.
 Just like BoxLayout or FlowLayout would do along one
axis.
 The position of each component is defined as being
relative to the preceding component.
 The second way places the components in
parallel, on top of each other in the same
space, and aligned along a common
reference point.
 For example, the components can be right-
aligned along the horizontal axis, or baseline-
aligned along the vertical axis, etc.
 public GroupLayout(Container host)
 Creates a GroupLayout for the specified Container.
 Parameters: host - the Container the GroupLayout is the
LayoutManager.
 public void
setAutoCreateGaps(boolean autoCreatePadding)
 Sets whether a gap between components should automatically
be created.
 public boolean getAutoCreateGaps()
 Returns true if gaps between components are automatically
created.
 Returns: true if gaps between components are automatically
created
 public GroupLayout.SequentialGroup
createSequentialGroup()
 Creates and returns a SequentialGroup.
 Returns: a new SequentialGroup
 public GroupLayout.ParallelGroup
createParallelGroup()
 Creates and returns a ParallelGroup with an alignment of
Alignment.LEADING. This is a cover method for the more general
createParallelGroup(Alignment) method.
 public void replace (Component existingComponent,
Component newComponent)
 Replaces an existing component with a new one.
 existingComponent - the component that should be removed and
replaced with newComponent
 newComponent - the component to put in existingComponent's
place
 public void addLayoutComponent(String name,
Component component)
 Notification that a Component has been added to the parent
container. You should not invoke this method directly, instead you
should use one of the Group methods to add a Component.
 Demo of GroupLayout

More Related Content

What's hot

Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Fragment
Fragment Fragment
Java collections concept
Java collections conceptJava collections concept
Java collections concept
kumar gaurav
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
soumyaharitha
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
Prashanth Shivakumar
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
suraj pandey
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
Arati Gadgil
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
Surbhi Panhalkar
 
Files in php
Files in phpFiles in php
Files in php
sana mateen
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
srijavel
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
Muthukumaran Subramanian
 
Finalize() method
Finalize() methodFinalize() method
Finalize() method
Jadavsejal
 

What's hot (20)

Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Fragment
Fragment Fragment
Fragment
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Event handling
Event handlingEvent handling
Event handling
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Files in php
Files in phpFiles in php
Files in php
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Finalize() method
Finalize() methodFinalize() method
Finalize() method
 
Packages in java
Packages in javaPackages in java
Packages in java
 

Viewers also liked

Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menusmyrajendra
 
Layouts - Java
Layouts - JavaLayouts - Java
Layouts - Javanjca01
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
raksharao
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
raksharao
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 

Viewers also liked (7)

Java
JavaJava
Java
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
 
Layouts - Java
Layouts - JavaLayouts - Java
Layouts - Java
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Android ppt
Android ppt Android ppt
Android ppt
 

Similar to Layout manager

3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
abhishekmathuroffici
 
Understanding layout managers
Understanding layout managersUnderstanding layout managers
Understanding layout managers
Nuha Noor
 
Layout managementand event handling
Layout managementand event handlingLayout managementand event handling
Layout managementand event handlingCharli Patel
 
Chap1 1.4
Chap1 1.4Chap1 1.4
Chap1 1.4
Hemo Chella
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
ssuserec53e73
 
Javalayout
JavalayoutJavalayout
java swing
java swingjava swing
java swing
Waheed Warraich
 
Chap1 1 4
Chap1 1 4Chap1 1 4
Chap1 1 4
Hemo Chella
 
Java Graphics
Java GraphicsJava Graphics
Java Graphics
Shraddha
 
Java swing
Java swingJava swing
Java swing
ssuser3a47cb
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
DrRajeshreeKhande
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
PBMaverick
 
8layout Managers
8layout Managers8layout Managers
8layout ManagersAdil Jafri
 
JFree chart
JFree chartJFree chart
Java card and flow layout
Java card and flow layoutJava card and flow layout
Java card and flow layout
shiprashakya2
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
vanmathy1
 
LAYOUT.pptx
LAYOUT.pptxLAYOUT.pptx
LAYOUT.pptx
aparna14patil
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 
Java gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docxJava gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docx
olsenlinnea427
 

Similar to Layout manager (20)

Module 2
Module 2Module 2
Module 2
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
Understanding layout managers
Understanding layout managersUnderstanding layout managers
Understanding layout managers
 
Layout managementand event handling
Layout managementand event handlingLayout managementand event handling
Layout managementand event handling
 
Chap1 1.4
Chap1 1.4Chap1 1.4
Chap1 1.4
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
 
Javalayout
JavalayoutJavalayout
Javalayout
 
java swing
java swingjava swing
java swing
 
Chap1 1 4
Chap1 1 4Chap1 1 4
Chap1 1 4
 
Java Graphics
Java GraphicsJava Graphics
Java Graphics
 
Java swing
Java swingJava swing
Java swing
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
 
8layout Managers
8layout Managers8layout Managers
8layout Managers
 
JFree chart
JFree chartJFree chart
JFree chart
 
Java card and flow layout
Java card and flow layoutJava card and flow layout
Java card and flow layout
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 
LAYOUT.pptx
LAYOUT.pptxLAYOUT.pptx
LAYOUT.pptx
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Java gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docxJava gives us layout managers whose responsibility it is to determine.docx
Java gives us layout managers whose responsibility it is to determine.docx
 

More from Shree M.L.Kakadiya MCA mahila college, Amreli

Machine Learning by Rj
Machine Learning by RjMachine Learning by Rj
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Servlet unit 2
Servlet unit 2 Servlet unit 2
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Motion capture by Rj
Motion capture by RjMotion capture by Rj
Research paper on big data and hadoop
Research paper on big data and hadoopResearch paper on big data and hadoop
Research paper on big data and hadoop
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Text processing by Rj
Text processing by RjText processing by Rj
Python and data analytics
Python and data analyticsPython and data analytics
Multithreading by rj
Multithreading by rjMultithreading by rj
Database programming
Database programmingDatabase programming
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Seminar on Project Management by Rj
Seminar on Project Management by RjSeminar on Project Management by Rj
Seminar on Project Management by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Spring by rj
Spring by rjSpring by rj
Python by Rj
Python by RjPython by Rj
Leadership & Motivation
Leadership & MotivationLeadership & Motivation

More from Shree M.L.Kakadiya MCA mahila college, Amreli (20)

Machine Learning by Rj
Machine Learning by RjMachine Learning by Rj
Machine Learning by Rj
 
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
 
Servlet unit 2
Servlet unit 2 Servlet unit 2
Servlet unit 2
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
Networking in python by Rj
Networking in python by RjNetworking in python by Rj
Networking in python by Rj
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
Motion capture by Rj
Motion capture by RjMotion capture by Rj
Motion capture by Rj
 
Research paper on big data and hadoop
Research paper on big data and hadoopResearch paper on big data and hadoop
Research paper on big data and hadoop
 
Text processing by Rj
Text processing by RjText processing by Rj
Text processing by Rj
 
Python and data analytics
Python and data analyticsPython and data analytics
Python and data analytics
 
Multithreading by rj
Multithreading by rjMultithreading by rj
Multithreading by rj
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Database programming
Database programmingDatabase programming
Database programming
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
Seminar on Project Management by Rj
Seminar on Project Management by RjSeminar on Project Management by Rj
Seminar on Project Management by Rj
 
Spring by rj
Spring by rjSpring by rj
Spring by rj
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Leadership & Motivation
Leadership & MotivationLeadership & Motivation
Leadership & Motivation
 

Recently uploaded

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Layout manager

  • 1. Layout Manager  FlowLayout  BorderLayout  CardLayout  GridLayout  GridBagLayout with  GridBagConstraints  Intro. to BoxLayout, SprigLayout,GroupLayout  Using NO LAYOUT Manager
  • 2. Layout Manager  The layout manager decides how the controls should be arranged or positioned within a container or a window.  In java there is no such form designer, but you have to write the code to arrange the controls where you want them.  A layout manager is an object of a class the implements the LayoutManager interface.
  • 3.  To set the layout following method is used:  Void setLayout(LayoutManager obj)  The obj is an object of the specified layout manager.  If no layout manager is set by setLayout() method, the default layout manager is used which is the FlowLayout.
  • 4. FlowLayout Class  The FlowLayout is the default layout manager.  If no layout manager is set by the setLayout() method, this layout is used to arrange the controls in a container.  In FlowLayout manager, the components are arranged the from the upper-left corner to the right side edge of the container.  When there is no space for the component, it is arranged from the next line.  A little space is added between each component at all of the four sides.
  • 5. Constructors  FlowLayout()  FlowLayout(int align)  FlowLayout(int align,hspace, vspace)  Alignment can be done by following  FlowLayout.CENTER //is default  FlowLayout.LEFT  FlowLayout.RIGHT  Hspace and vspace is the horizontal and vertical spaces between the components.  The default space is 5 pixels from both horizontal and vertical.
  • 6. Methods of FlowLayout  public int getAlignment()  Gets the alignment for this layout.  Possible values are FlowLayout.LEFT, FlowLayout.RIGHT,FlowLayout.CENTER,  Returns: the alignment value for this layout.  public void setAlignment(int align)  Sets the alignment for this layout. Possible values are  FlowLayout.LEFT  FlowLayout.RIGHT  FlowLayout.CENTER  Parameters: align - one of the alignment values shown above
  • 7.  public int getHgap()  Gets the horizontal gap between components and between the components and the borders of the Container  public void setHgap(int hgap)  Sets the horizontal gap between components and between the components and the borders of the Container.  public int getVgap()  Gets the vertical gap between components and between the components and the borders of the Container.  public void setVgap(int vgap)  Sets the vertical gap between components and between the components and the borders of the Container.
  • 8.  Demo of FlowLayout Class
  • 9. BorderLayout class  A border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center.  Each region may contain more than one component, and is identified by a corresponding constant: NORTH, SOUTH, EAST, WEST, and CENTER.  When adding a component to a container with a border layout, use one of these five constants.
  • 10. Constructors  public BorderLayout()  Constructs a new border layout with no gaps between components.  public BorderLayout(int hgap,int vgap)  Constructs a border layout with the specified gaps between components. The horizontal gap is specified by hgap and the vertical gap is specified by vgap.  hgap - the horizontal gap.  vgap - the vertical gap.  BorderLayout defines the following constants that specify the regions:  BorderLayout.CENTER  BorderLayout.SOUTH  BorderLayout.EAST  BorderLayout.WEST  BorderLayout.NORTH
  • 11.  When adding components, you will use these constants with the following form of add( ), which is defined by Container:  void add(Component compObj, Object region)  Here, compObj is the component to be added, and region specifies where the componentwill be added.
  • 12. Methods of BorderLayout  public int getHgap()  Returns the horizontal gap between components  public void setHgap(int hgap)  Sets the horizontal gap between components.  public int getVgap()  Returns the vertical gap between components.  public void setVgap(int vgap)  Sets the vertical gap between components.
  • 13.  Demo of BorderLayout Class
  • 14. CardLayout  The card layout has some special capabilities that other layout don’t have.  The card layout creates a layout like the playing the cards.  Assume more than one card on one another. Here, only the card on the top is visible at a time, but you shuffle the cards to see other hands.  Same way, the CardLayout can switch among several panels.
  • 15.  The cards are typically held in an object of type Panel. This panel must have CardLayout selected as its layout manager.  The cards that form the deck are also typically objects of type Panel.  Thus, you must create a panel that contains the deck and a panel for each card in the deck.  Next, you add to the appropriate panel the components that form each card.  You then add these panels to the panel for which CardLayout is the layout manager.  Finally, you add this panel to the main applet panel. Once these steps are complete, you must provide some way for the user to select between cards.
  • 16.  One common approach is to include one push button for each card in the deck.  When card panels are added to a panel, they are usually given a name.  Thus, most of the time, you will use this form of add( ) when adding cards to a panel:  void add (Component panelObj, Object name);  Here, name is a string that specifies the name of the card whose panel is specified by panelObj.
  • 17. Constructors  public CardLayout()  Creates a new card layout with gaps of size zero.  public CardLayout (int hgap,int vgap)  Creates a new card layout with the specified horizontal and vertical gaps.  The horizontal gaps are placed at the left and right edges.  The vertical gaps are placed at the top and bottom edges.  Parameters:  hgap - the horizontal gap.  vgap - the vertical gap.
  • 18. Methods of CardLayout  public void first (Container parent)  Flips to the first card of the container.  public void next (Container parent)  Flips to the next card of the specified container. If the currently visible card is the last one, this method flips to the first card in the layout.  public void previous (Container parent)  Flips to the previous card of the specified container. If the currently visible card is the first one, this method flips to the last card in the layout.  public void last (Container parent)  Flips to the last card of the container.  public void show (Container parent,String name)  Flips to the component that was added to this layout with the specified name, using addLayoutComponent. If no such component exists, then nothing happens.
  • 19.  public int getHgap()  Gets the horizontal gap between components.  Returns: the horizontal gap between components.  public void setHgap(int hgap)  Sets the horizontal gap between components.  Parameters: hgap - the horizontal gap between components.  public int getVgap()  Gets the vertical gap between components.  Returns: the vertical gap between components.  public void setVgap(int vgap)  Sets the vertical gap between components.  Parameters: vgap - the vertical gap between components.
  • 20.  Demo of CardLayout using JFrame  Demo of CardLayout using Panel  Demo of CardLayout using Panel
  • 21. GridLayout  The GridLayout class creates a layout which has a grid of rows and columns.  The GridLayout class is a layout manager that lays out a container's components in a rectangular grid.  The container is divided into equal-sized rectangles, and one component is placed in each rectangle.
  • 22. Constructors  public GridLayout()  Creates a grid layout with a default of one column per component, in a single row.  public GridLayout (int rows,int cols)  Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size.  One, but not both, of rows and cols can be zero, which means that any number of objects can be placed in a row or in a column.  public GridLayout (int rows,int cols,int hgap,int vgap)  Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size.  rows - the rows, with the value zero meaning any number of rows  cols - the columns, with the value zero meaning any number of columns  hgap - the horizontal gap  vgap - the vertical gap
  • 23. Methods  public int getRows()  Gets the number of rows in this layout.  public void setRows (int rows)  Sets the number of rows in this layout to the specified value.  public int getColumns()  Gets the number of columns in this layout.  public void setColumns (int cols)  Sets the number of columns in this layout to the specified value.  public int getHgap()  Gets the horizontal gap between components.  public void setHgap (int hgap)  Sets the horizontal gap between components to the specified value.  - public int getVgap ()  Gets the vertical gap between components.  public void setVgap (int vgap)  Sets the vertical gap between components to the specified value.
  • 24.  Demo of GridLayout with JFrame  Demo of GridLayout with JApplet
  • 25. GridBagLayout  The GridBagLayout is very flexible layout manager.  It is an extension of GridLayout that provides some more features than the GridLayout.  In the GridLayout all the cells have same height and width which is not necessary in the GridBagLayout.  Here, you can have cells of arbitrary width and height.  This can be done by specifying constraints.  To specify constraints you have to create an object of GridBagConstrains.
  • 26.  Position, size, and properties of components are determined by setting the GridBagConstraints of the GridBagLayout to particular values before the component is added to the container.  GridBagConstraints specify: 1. Location and size of the component on the grid. 2. Position and size of the component within the rectangular region specified in 1. 3. Behavior of the component and its region when the container is resized.
  • 27. Steps for Using a GridBag 1. Create a GridBagLayout object, say gbl, and set it to be the layout manager of the Container.  GridBagLayout gbl = new GridBagLayout();  setLayout(gbl); 2. Create a GridBagConstraints object, say gbc, and provide values for its public instance variables for each Component, in turn, to be placed on the Container.  GridBagConstraints gbc = new GridBagConstraints(); 3. Place component using  gbl.setConstraints (component, gbc);  add(component);  or  add(component, gbc);
  • 28. Instance variables that you can set to GridBagConstraints  gridx and gridy  girdx specifies the horizontal position and gridy specifies the vertical position of the component.  The left most components have the gridx=0 and the upper most components have the gridy=0.  The default value is GridBagConstraints.RELATIVE which places the components just right to the previously added component for gridx and just below to the previously added component for gridy.
  • 29.  gridwidth and gridheight  The gridwidth specify the width and gridheight specifies height of the cell in number of rows and number of columns respectively.  The height and width is in number of cells and not in pixels.  The default value is 1 for both.  fill  It specifies what to do Its valid values are:if the component’s size is larger than the size of the cell.  GridBagConstraints.NONE: default value
  • 30.  GridBagConstraints.HORIZONTAL  it changes the width of the component to fit in the cell. It does not change the height of the component.  GridBagConstraints.VERTICAL  it changes the height of the component to fit in the cell. It does not change the width of the component.  GridBagConstraints.BOTH  it changes both height and width of the component to fit in the cell.
  • 31.  ipadx and ipady  They specifies the internal padding of the component means it specifies that how many space will remain around the component in the cell.  the ipadx specifies the horizontal space and the ipady specifies the vertical space in pixels.  The default value is 0 for both.  weightx and weighty  The weightx and weighty specify the horizontal and vertical space between the edge of the container and the cells respectively.  The default value is 0.0
  • 32.  int anchor  Tells where the component is positioned in its allocated region, one of CENTER, NORTH, EAST, SOUTH, WEST, NORTHEAST, SOUTHEAST, SOUTHWEST, or NORTHWEST.  Default: CENTER
  • 33.  Demo of GridBagLayout
  • 34. BoxLayout  The BoxLayout is a general purpose layout manager which is an extension of FlowLayout.  It places the components on top of each other or places them one after another in a row.  Constructor  public BoxLayout(Container obj, int axis)  Creates a layout manager that will lay out components along the given axis.  obj – is the object of a container such as panel.  axis - the axis to lay out components along.  BoxLayout.X_AXIS,  BoxLayout.Y_AXIS,  BoxLayout.LINE_AXIS or  BoxLayout.PAGE_AXIS
  • 35.  There are four axis:  public static final int X_AXIS  Specifies that components should be laid out left to right.  public static final int Y_AXIS  Specifies that components should be laid out top to bottom.  public static final int LINE_AXIS  it places the components in a line, one after another  public static final int PAGE_AXIS  It places the components like stack. On the top of each other.
  • 36.  Demo of BoxLayout
  • 37. Spring Layout  The Spring Layout is a very flexible layout that has many features for specifying the size of the components.  You can have different size rows and/or columns in a container.  In Spring Layout you can define a fixed distance between the left edge of one component and right edge of another component.
  • 38.  public SpringLayout()  Constructs a new SpringLayout.  void putConstraint (string edge1,component obj1,int distance, string edge2 ,component obj2)  void putConstraint (string edge1,component obj1,spring distance, string edge2 ,component obj2)  In this edge value can be one of the following:  SpringLayout.NORTH  SpringLayout.EAST  SpringLayout.WEST  SpringLayout.SOUTH
  • 39.  Demo of SpringLayout
  • 40. Group Layout  GroupLayout is a LayoutManager that hierarchically groups components in order to position them in a Container.  Grouping is done by instances of the Group class.  GroupLayout uses two types of arrangements – sequential and parallel, combined with hierarchical composition.  With sequential arrangement, the components are simply placed one after another.  Just like BoxLayout or FlowLayout would do along one axis.  The position of each component is defined as being relative to the preceding component.
  • 41.  The second way places the components in parallel, on top of each other in the same space, and aligned along a common reference point.  For example, the components can be right- aligned along the horizontal axis, or baseline- aligned along the vertical axis, etc.
  • 42.  public GroupLayout(Container host)  Creates a GroupLayout for the specified Container.  Parameters: host - the Container the GroupLayout is the LayoutManager.  public void setAutoCreateGaps(boolean autoCreatePadding)  Sets whether a gap between components should automatically be created.  public boolean getAutoCreateGaps()  Returns true if gaps between components are automatically created.  Returns: true if gaps between components are automatically created  public GroupLayout.SequentialGroup createSequentialGroup()  Creates and returns a SequentialGroup.  Returns: a new SequentialGroup
  • 43.  public GroupLayout.ParallelGroup createParallelGroup()  Creates and returns a ParallelGroup with an alignment of Alignment.LEADING. This is a cover method for the more general createParallelGroup(Alignment) method.  public void replace (Component existingComponent, Component newComponent)  Replaces an existing component with a new one.  existingComponent - the component that should be removed and replaced with newComponent  newComponent - the component to put in existingComponent's place  public void addLayoutComponent(String name, Component component)  Notification that a Component has been added to the parent container. You should not invoke this method directly, instead you should use one of the Group methods to add a Component.
  • 44.  Demo of GroupLayout