SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 

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