Your SlideShare is downloading. ×
0
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Module 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Module 2

265

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
265
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. LayoutManagers
  • 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-dependentpositioning?
  • 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
  • 26. CardLayout
  • 27. CardLayout CardLayout() CardLayout(int horizontal_gap, int vertical_gap)
  • 28. CardLayout
  • 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 thesame space in the container Dis. Not visually appealing as a Tabbed pane Requires other components like buttons or drop-down to flipthrough

×