Layout managers arrange components in containers. The default is FlowLayout. Other layout managers include BorderLayout, GridLayout, CardLayout, and GridBagLayout. Each layout manager positions components differently - for example, BorderLayout uses fixed areas, GridBagLayout arranges components in a grid using constraints.
1 of 12
More Related Content
Javalayout
1. Layout ManagerLayout Manager
?Arranges the layout of window containing diffArranges the layout of window containing diff
controls.controls.
?Default is the flow LayoutDefault is the flow Layout
?setLayout() :setLayout() :
void setLayout(Layout Managervoid setLayout(Layout Manager
lyoutObj)lyoutObj)
?Disable layout by passingDisable layout by passing nullnull for objectfor object
?Component can be manually placed byComponent can be manually placed by
usingusing setBounds()setBounds()
?minimumLayoutSize()minimumLayoutSize()
?preferredLayoutSize()preferredLayoutSize()
3. FlowLayoutFlowLayout
? It is default flowlayoutIt is default flowlayout
? Implements simple layout styleImplements simple layout style
? Constructor are-Constructor are-
- FlowLayout()FlowLayout()
- FlowLayout(int how)FlowLayout(int how)
- FlowLayout(int how, int horz, int vert )FlowLayout(int how, int horz, int vert )
? Valid values for how-Valid values for how-
? FlowLayout.LEFTFlowLayout.LEFT
? FlowLayout.RIGHTFlowLayout.RIGHT
? FlowLayout.CENTERFlowLayout.CENTER
4. BorderLayoutBorderLayout
? The border layout has four narrow, fixed-The border layout has four narrow, fixed-
width components at the edges & 1 largewidth components at the edges & 1 large
area in the centerarea in the center
? Constructor of BorderLayout are-Constructor of BorderLayout are-
-BorderLayout()-BorderLayout()
-BorderLayout(int horz, int vert)-BorderLayout(int horz, int vert)
? Component can be used with add() methodComponent can be used with add() method
Void add(component compobj, ObjectVoid add(component compobj, Object
region)region)
5. BorderLayoutBorderLayout
? BorderLayout Defines certain regionBorderLayout Defines certain region
-BorderLayout.CENTER-BorderLayout.CENTER
-BorderLayout.SOUTH-BorderLayout.SOUTH
-BorderLayout.EAST-BorderLayout.EAST
-BorderLayout.WEST-BorderLayout.WEST
-BorderLayoutNORTH-BorderLayoutNORTH
6. GridLayoutGridLayout
? Used to layout Component in twoUsed to layout Component in two
dimensional griddimensional grid
? Need to define no. of rows & col.Need to define no. of rows & col.
? Constructors are-Constructors are-
--GridLayout ()GridLayout ()
- GridLayout(int noRows, int noCols)GridLayout(int noRows, int noCols)
- GridLayout(int noRows, int noCols, int horz, int vert)GridLayout(int noRows, int noCols, int horz, int vert)
7. CardLayoutCardLayout
? The CardLayout class manages the components inThe CardLayout class manages the components in
such a manner that only one component is visible atsuch a manner that only one component is visible at
a time. It treats each component as a card that isa time. It treats each component as a card that is
why it is known as CardLayout.why it is known as CardLayout.
? Constructor are-Constructor are-
? CardLayout( )CardLayout( )
? CardLayout(intCardLayout(int horz, int vert)horz, int vert)
? use this form of add( ) when adding cards to a paneluse this form of add( ) when adding cards to a panel
? void add(Componentvoid add(Component panelObj, Object name)panelObj, Object name)
9. GridbagLayoutGridbagLayout
? The class GridBagLayout arranges components inThe class GridBagLayout arranges components in
a horizontal and vertical manner Implements simplea horizontal and vertical manner Implements simple
layout stylelayout style
? each GridBagLayout object maintains a dynamic,each GridBagLayout object maintains a dynamic,
rectangular grid of cells, with each componentrectangular grid of cells, with each component
occupying one or more cellsoccupying one or more cells
? Constructor are-Constructor are-
? GridBagLayout()GridBagLayout()
? Method used to set constraintsMethod used to set constraints
-void setContsraints(Component-void setContsraints(Component
comp,Gridbagconstraints cns)comp,Gridbagconstraints cns)
10. GridbagLayoutGridbagLayout
?Absolute ValuesAbsolute Values
? GridBagConstraints.NORTHGridBagConstraints.NORTH
GridBagConstraints.SOUTHGridBagConstraints.SOUTH
GridBagConstraints.WESTGridBagConstraints.WEST
GridBagConstraints.EASTGridBagConstraints.EAST
GridBagConstraints.NORTHWESTGridBagConstraints.NORTHWEST
GridBagConstraints.NORTHEASTGridBagConstraints.NORTHEAST
GridBagConstraints.SOUTHWESTGridBagConstraints.SOUTHWEST
GridBagConstraints.SOUTHEASTGridBagConstraints.SOUTHEAST
GridBagConstraints.CENTER (the default)GridBagConstraints.CENTER (the default)
MFC was introduced in 1992.
VB created in 1991. Replaced by VB.NET. MS stopped supporting VB in 2005.
ASP first developed in 1996. Used VBScript.
^Write once, test everywhere. ̄ C Hooks to OS or hardware specific devices means Java code must be changed.
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?
C#'s principal designer and lead architect at Microsoft is Anders Hejlsberg who also developed Turbo Pascal, Borland Delphi, and Visual J++.
C++/CLI (Common Language Infrastructure) supersedes managed C++. It contains new syntax that helps clarify if using managed or unmanaged memory.
http://en.wikipedia.org/wiki/C%2B%2B/CLI
Managed vs. unmanaged code. What is the advantage of running managed code? Of running unmanaged code?