SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Layout
Managers
What is a Layout Manager?
     a object associated with a container
            which governs the placement and size of the component
All containers
     whether top-level or general-purpose
           are based on a Layout Manager.
JFrame, JApplet has BorderLayout by default
Why needs Layout Manager?
Normal not Layout Manager:
    Set an absolute size for components
What happens when the user resize a window?
     How does my component look like?

How you guys solve platform-dependent
positioning?
Okay. Layout Manager takes care of this for you.
LayoutManager based on
    minimumSize, preferedSize, maximumSize
          to resize and arrange components on the screen
Steps for using Layout Managers
     1. setLayout()
       Container contentPane = frame.getContentPane();
       contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
Steps for using Layout Managers
     2. specify size
            | void setPreferredSize(Dimension preferredSize)
            | void setMinimumSize(Dimension minimumSize)
            | void setMaximumSize(Dimension maximumSize)

            | btnOk.setPreferredSize(new Dimension (20,20))
Steps for using Layout Managers
     3. pack()
     4. setVisible()
Types of Layout Manager
     FlowLayout
     BorderLayout
Types of Layout Manager
     GridLayout



     CardLayout
FlowLayout
    Constructors
          public FlowLayout()
          public FlowLayout(int alignment)
          public FlowLayout(int alignment, int hgap, int vgap)
FlowLayout
    Alignments:
          CENTER
          LEADING
          LEFT
          RIGHT
          TRAILING
FlowLayout
    Benefits
          Simple to use
          Centers layout for bigger container
          Suitable for JApplet
FlowLayout
    Drawbacks
         Resize loose alignment
         No complex alighment
BorderLayout
    by default in center
BorderLayout
    Alignment
          AFTER_LAST_LINE, PAGE_END, SOUTH
          AFTER_LINE_ENDS, LINE_END, EAST
          BEFORE_FIRST_LINE, PAGE_START, NORTH
          BEFORE_LINE_BEGINS, LINE_START, WEST
          CENTER
BorderLayout
    Constructor
          public BorderLayout()

          public BorderLayout(int hgap, int vgap)
BorderLayout
    Adv.
           Can specify direction

    Dis.
           Only five locations to add components
           No high complexity
GridLayout
     setLayout(new GridLayout(3, 4))
GridLayout
     public GridLayout()
     public GridLayout(int rows, int columns)
     public GridLayout(int rows, int columns, int hgap, int vgap)
GridLayout
     Adv.
             Simple to use
             Useful for rectangular pattern
             Same size component

     Dis.
             Cannot create a complex layout
CardLayout
CardLayout
    CardLayout()
    CardLayout(int horizontal_gap, int vertical_gap)
CardLayout
CardLayout
    void first(Container parent)
    void next(Container parent)
    void previous(Container parent)
    void last(Container parent)
CardLayout
          Adv.
                 Containers and their associated components to share the
same space in the container

          Dis.
                 Not visually appealing as a Tabbed pane
                 Requires other components like buttons or drop-down to flip
through

Más contenido relacionado

Destacado

Shifts in the music industry
Shifts in the music industryShifts in the music industry
Shifts in the music industry
sadieolen
 
Tensioned Membrane Structures In India
Tensioned Membrane Structures In IndiaTensioned Membrane Structures In India
Tensioned Membrane Structures In India
Ravindra Mehta
 
Ch. 10 -_motivation and engagement
Ch. 10 -_motivation and engagementCh. 10 -_motivation and engagement
Ch. 10 -_motivation and engagement
Peapod Ledesma
 
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
Angad Singh
 
Linseele,v.s af a2006- pastoralists in africa
Linseele,v.s af a2006- pastoralists in africaLinseele,v.s af a2006- pastoralists in africa
Linseele,v.s af a2006- pastoralists in africa
sahiloct11969
 
Paper mill – comana, romania
Paper mill – comana, romaniaPaper mill – comana, romania
Paper mill – comana, romania
balada65
 
Smsvideoconferencing slideshare
Smsvideoconferencing slideshareSmsvideoconferencing slideshare
Smsvideoconferencing slideshare
Eleanor Schuster
 
Morgana matariki pp presentation
Morgana matariki pp presentationMorgana matariki pp presentation
Morgana matariki pp presentation
lesleymccardle
 

Destacado (20)

Shifts in the music industry
Shifts in the music industryShifts in the music industry
Shifts in the music industry
 
Corespring
CorespringCorespring
Corespring
 
Tensioned Membrane Structures In India
Tensioned Membrane Structures In IndiaTensioned Membrane Structures In India
Tensioned Membrane Structures In India
 
Basic conversation 5
Basic conversation 5Basic conversation 5
Basic conversation 5
 
O3sac energia-jpb 2012
O3sac energia-jpb 2012O3sac energia-jpb 2012
O3sac energia-jpb 2012
 
Egoera: La economía de Bizkaia - Mayo 2016 - nº22. Cámara de Comercio de Bilbao
Egoera: La economía de Bizkaia - Mayo 2016 - nº22. Cámara de Comercio de BilbaoEgoera: La economía de Bizkaia - Mayo 2016 - nº22. Cámara de Comercio de Bilbao
Egoera: La economía de Bizkaia - Mayo 2016 - nº22. Cámara de Comercio de Bilbao
 
Developing your School's WOM Marketing Plan, TAIS 2012
Developing your School's WOM Marketing Plan, TAIS 2012Developing your School's WOM Marketing Plan, TAIS 2012
Developing your School's WOM Marketing Plan, TAIS 2012
 
Startgids Accounthouder
Startgids AccounthouderStartgids Accounthouder
Startgids Accounthouder
 
Big data movement webcast
Big data movement webcastBig data movement webcast
Big data movement webcast
 
Ch. 10 -_motivation and engagement
Ch. 10 -_motivation and engagementCh. 10 -_motivation and engagement
Ch. 10 -_motivation and engagement
 
Ts 4783 1
Ts 4783 1Ts 4783 1
Ts 4783 1
 
Denúncia da Lava Jato contra João Santana
Denúncia da Lava Jato contra João SantanaDenúncia da Lava Jato contra João Santana
Denúncia da Lava Jato contra João Santana
 
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
Can Social Media Influence Behavior - We Walk the Talk - CS377T Final Present...
 
Linseele,v.s af a2006- pastoralists in africa
Linseele,v.s af a2006- pastoralists in africaLinseele,v.s af a2006- pastoralists in africa
Linseele,v.s af a2006- pastoralists in africa
 
Basketball game
Basketball gameBasketball game
Basketball game
 
Paper mill – comana, romania
Paper mill – comana, romaniaPaper mill – comana, romania
Paper mill – comana, romania
 
Smsvideoconferencing slideshare
Smsvideoconferencing slideshareSmsvideoconferencing slideshare
Smsvideoconferencing slideshare
 
Creative Technosoft System - Company Profile
Creative Technosoft System - Company ProfileCreative Technosoft System - Company Profile
Creative Technosoft System - Company Profile
 
Research designku rev
Research designku revResearch designku rev
Research designku rev
 
Morgana matariki pp presentation
Morgana matariki pp presentationMorgana matariki pp presentation
Morgana matariki pp presentation
 

Similar a Module 2

8layout Managers
8layout Managers8layout Managers
8layout Managers
Adil Jafri
 
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
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
ssuserec53e73
 
9awt Components
9awt Components9awt Components
9awt Components
Adil Jafri
 
GridBagLayout Quick Start
GridBagLayout Quick StartGridBagLayout Quick Start
GridBagLayout Quick Start
Guo Albert
 

Similar a Module 2 (20)

Layout manager
Layout managerLayout manager
Layout manager
 
8layout Managers
8layout Managers8layout Managers
8layout Managers
 
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
 
Java
JavaJava
Java
 
Javalayout
JavalayoutJavalayout
Javalayout
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
 
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
 
Understanding layout managers
Understanding layout managersUnderstanding layout managers
Understanding layout managers
 
java-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdfjava-layoutmanager-151027135512-lva1-app6892.pdf
java-layoutmanager-151027135512-lva1-app6892.pdf
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
swingbasics
swingbasicsswingbasics
swingbasics
 
java swing
java swingjava swing
java swing
 
9awt Components
9awt Components9awt Components
9awt Components
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6
 
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
3_ppt_Layout.pptxgßbdbdbdbsbsbsbbsbsbsbsbsb
 
Advanced Java programming
Advanced Java programmingAdvanced Java programming
Advanced Java programming
 
Chap1 1 4
Chap1 1 4Chap1 1 4
Chap1 1 4
 
LayoutManager_Lec1.pptx
LayoutManager_Lec1.pptxLayoutManager_Lec1.pptx
LayoutManager_Lec1.pptx
 
Android Development - ConstraintLayout
Android Development - ConstraintLayoutAndroid Development - ConstraintLayout
Android Development - ConstraintLayout
 
GridBagLayout Quick Start
GridBagLayout Quick StartGridBagLayout Quick Start
GridBagLayout Quick Start
 

Más de Tuan Ngo

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
Tuan Ngo
 
Net framework
Net frameworkNet framework
Net framework
Tuan Ngo
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
Tuan Ngo
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iterators
Tuan Ngo
 
13 collections
13   collections13   collections
13 collections
Tuan Ngo
 
11 exception handling
11   exception handling11   exception handling
11 exception handling
Tuan Ngo
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegates
Tuan Ngo
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexers
Tuan Ngo
 
10 namespace
10  namespace10  namespace
10 namespace
Tuan Ngo
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
Tuan Ngo
 
7 inheritance and polymorphism
7   inheritance and polymorphism7   inheritance and polymorphism
7 inheritance and polymorphism
Tuan Ngo
 
6 class and methods
6    class and methods6    class and methods
6 class and methods
Tuan Ngo
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operators
Tuan Ngo
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructs
Tuan Ngo
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
Tuan Ngo
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data types
Tuan Ngo
 

Más de Tuan Ngo (20)

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
 
Net framework
Net frameworkNet framework
Net framework
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iterators
 
13 collections
13   collections13   collections
13 collections
 
11 exception handling
11   exception handling11   exception handling
11 exception handling
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegates
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexers
 
10 namespace
10  namespace10  namespace
10 namespace
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
 
7 inheritance and polymorphism
7   inheritance and polymorphism7   inheritance and polymorphism
7 inheritance and polymorphism
 
5 arrays
5   arrays5   arrays
5 arrays
 
6 class and methods
6    class and methods6    class and methods
6 class and methods
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operators
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructs
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data types
 
Jdbc 7
Jdbc 7Jdbc 7
Jdbc 7
 
Jdbc 6
Jdbc 6Jdbc 6
Jdbc 6
 
Jdbc 3
Jdbc 3Jdbc 3
Jdbc 3
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Module 2

  • 2. What is a Layout Manager? a object associated with a container which governs the placement and size of the component
  • 3. All containers whether top-level or general-purpose are based on a Layout Manager.
  • 4. JFrame, JApplet has BorderLayout by default
  • 5. Why needs Layout Manager?
  • 6. Normal not Layout Manager: Set an absolute size for components
  • 7. What happens when the user resize a window? How does my component look like? How you guys solve platform-dependent positioning?
  • 8. Okay. Layout Manager takes care of this for you.
  • 9. LayoutManager based on minimumSize, preferedSize, maximumSize to resize and arrange components on the screen
  • 10. Steps for using Layout Managers 1. setLayout() Container contentPane = frame.getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
  • 11. Steps for using Layout Managers 2. specify size | void setPreferredSize(Dimension preferredSize) | void setMinimumSize(Dimension minimumSize) | void setMaximumSize(Dimension maximumSize) | btnOk.setPreferredSize(new Dimension (20,20))
  • 12. Steps for using Layout Managers 3. pack() 4. setVisible()
  • 13. Types of Layout Manager FlowLayout BorderLayout
  • 14. Types of Layout Manager GridLayout CardLayout
  • 15. FlowLayout Constructors public FlowLayout() public FlowLayout(int alignment) public FlowLayout(int alignment, int hgap, int vgap)
  • 16. FlowLayout Alignments: CENTER LEADING LEFT RIGHT TRAILING
  • 17. FlowLayout Benefits Simple to use Centers layout for bigger container Suitable for JApplet
  • 18. FlowLayout Drawbacks Resize loose alignment No complex alighment
  • 19. BorderLayout by default in center
  • 20. BorderLayout Alignment AFTER_LAST_LINE, PAGE_END, SOUTH AFTER_LINE_ENDS, LINE_END, EAST BEFORE_FIRST_LINE, PAGE_START, NORTH BEFORE_LINE_BEGINS, LINE_START, WEST CENTER
  • 21. BorderLayout Constructor public BorderLayout() public BorderLayout(int hgap, int vgap)
  • 22. BorderLayout Adv. Can specify direction Dis. Only five locations to add components No high complexity
  • 23. GridLayout setLayout(new GridLayout(3, 4))
  • 24. GridLayout public GridLayout() public GridLayout(int rows, int columns) public GridLayout(int rows, int columns, int hgap, int vgap)
  • 25. GridLayout Adv. Simple to use Useful for rectangular pattern Same size component Dis. Cannot create a complex layout
  • 27. CardLayout CardLayout() CardLayout(int horizontal_gap, int vertical_gap)
  • 29. CardLayout void first(Container parent) void next(Container parent) void previous(Container parent) void last(Container parent)
  • 30. CardLayout Adv. Containers and their associated components to share the same space in the container Dis. Not visually appealing as a Tabbed pane Requires other components like buttons or drop-down to flip through