layout mangers in java l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Layout Mangers in Java PowerPoint Presentation
Download Presentation
Layout Mangers in Java

Loading in 2 Seconds...

play fullscreen
1 / 10

Layout Mangers in Java - PowerPoint PPT Presentation


  • 145 Views
  • Uploaded on

Layout Mangers in Java. Tim McKenna Seneca@York. Layout Managers. A container (JPanel) has a layout manager. A layout manager is an object that manages the size and location of the components inside a container. Layout Managers.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Layout Mangers in Java' - neka


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
layout mangers in java

Layout Mangers in Java

Tim McKenna

Seneca@York

layout managers
Layout Managers
  • A container (JPanel) has a layout manager.
  • A layout manager is an object that manages the size and location of the components inside a container.
layout managers3
Layout Managers
  • A top-level container (JFrame) has a "content pane" which can be set to a container (JPanel).
  • This container can contain other containers.
  • Containers can be associated with different layout managers.
containment hierarchy
Containment Hierarchy
  • a logical hierarchy of containers
  • nest containers inside other containersJPanel (inside JPanel …) inside JFrame
  • advantages
  • a more organized, cleaner GUI layout
  • new components can be added to one container without affecting the other containers
  • programming technique: use of panels inside panels, each with different layouts
use of panels
Use of Panels
  • Components are grouped into different containers, i.e. JPanels
  • Each container uses its own layout manager to position components.
  • Another container uses its layout manager to position the panels.
three common layout managers
Three Common Layout Managers
  • java.awt.FlowLayout
  • java.awt.BorderLayout
  • java.awt.GridLayout
flowlayout manager
FlowLayout Manager
  • default for panels and applets
  • multiple components placed from left to right, from top to bottom
  • alignment and spacing can be adj.
  • Example: FlowLayoutManager.java
  • Exercise: Resize the window and see how the components flow.
borderlayout manager
BorderLayout Manager
  • default for JFrame window objects
  • locations marked by 5 areas: NORTH, SOUTH, EAST, WEST, CENTER
  • each area can contain only ONE object,usually a JPanel object
  • sizing of the areas: NORTH, SOUTH: horizontal expansion EAST, WEST: vertical expansion CENTER: flows
  • Example: BorderLayoutManager.java
gridlayout manager
GridLayout Manager
  • locations: a grid of rows and columns
  • size of the components: equal size
  • Example: GridLayoutManager.java
layout managers10
Layout Managers
  • Flow/Border/Grid Layouts all have limited use.
  • GridBagLayout is much more flexible and much harder to use.
  • bobjects package JPanelGrid combines GridLayout ease of use and GridBagLayout power.
  • see JFrameJPanelGrid.java