Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers.

Slides:



Advertisements
Similar presentations
G5BUID - Java Swing Laying out components Manage realized components Determine size and position Each container has a layout manager (usually)
Advertisements

Introduction to Java 2 Programming
Unit 121 A layout manager is an object that determines the manner in which components are arranged in a container. Each layout manager implements one of.
Graphical User Interfaces
TCU CoSc Programming with Java Visual Design (Chapter 5)
Graphic User Interfaces Layout Managers Event Handling.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
® Microsoft Office 2010 Word Tutorial 3 Creating a Multiple-Page Report.
Chapter 9: Graphical User Interfaces Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
Chapter Day 16. © 2007 Pearson Addison-Wesley. All rights reserved6-2 Agenda Day 16 Problem set 3 posted  10 problems from chapters 5 & 6  Due in one.
Unit 131 GUI Layout Managers Learning Outcomes oList and distinguish between the four most common, standard layout managers in Java. oUse these and other.
Chapter Day 17. © 2007 Pearson Addison-Wesley. All rights reserved6-2 Agenda Day 17 Problem set 3 posted  10 problems from chapters 5 & 6  Due in 3.
1 L48 Advanced GUI Component (3). 2 OBJECTIVES  To use additional layout managers.
Aalborg Media Lab 28-Jun-15 Software Design Lecture 7 “Object Oriented Design”
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
ITEC220 GUI Lecture – Part 1 References  Java Software Solutions,” by Lewis & Loftus  Chapter 3  Chapter 4  Chapter 5  Chapter 6  Java Foundations-Introduction.
Copyright © 2012 Pearson Education, Inc. Chapters 3-8 Graphical User Interfaces Java Software Solutions Foundations of Program Design Seventh Edition John.
GUI and event-driven programming An introduction.
HTML Essentials Tables and Table Tags. Overview Use of Tables goes beyond tabulating data Frequently used to format Web pages / control layout Especially.
OOP (Java): Layout/ OOP Objectives – –describe the basic layout managers for GUIs Semester 2, GUI Layout.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
MSc Workshop - © S. Kamin, U.Reddy Lect 5 – GUI Prog - 1 Lecture 5 – GUI Programming r Inner classes  this and super r Layout r Reading: m.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Standard Graphics in Java.
Adding Graphics to a Frame Application Applets: Can generate drawings by overriding paint Frame: Do not draw directly on a frame. Draw graphics on a JPanel.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
XP New Perspectives on Microsoft PowerPoint 2002 Tutorial 2 1 Microsoft PowerPoint 2002 Tutorial 2 – Applying and Modifying Text and Graphic Objects.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Copyright 2006 South-Western/Thomson Learning Chapter 12 Tables.
Laying Out Components Interior Design for GUIs. Nov 042 What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame’s.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Microsoft ® Office 2007 PowerPoint Lecture to Accompany.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
Layout Manager Summary
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
University of Limerick1 Software Architecture Java Layout Managers.
3461 Laying Out Components Interior Design for GUIs.
CRSD Technology Training Tony Judice. Quick Access Toolbar – can be modifiedSave as… allows you to save the file to a different location and also as an.
By: Ms. Abeer Helwa 1. CREATE A WORD DOCUMENT 2 Blank document Templates To create a new blank document: click the File tab and click Blank document.
Csc Basic Graphical User Interface (GUI) Components.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 3 Designing the Interface with Layout Managers.
GUI I IS Outline  Quiz  Quiz solution  GUI components  Layout.
CSI 3125, Preliminaries, page 1 Layout Managers. CSI 3125, Preliminaries, page 2 Layout Managers The LayoutManagers are used to arrange components in.
Positioning Objects with CSS and Tables
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
XP IT INSTRUCTOR :AHMAD HIRZALLAH 1 Microsoft Office FrontPage 2003 Creating Tables and Frames.
Event Handler Methods Text field Object Responder JAVA AWT Environment: Messages are sent between JAVA Objects Screen Event Notification Press Button.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
Adding Tables to Slides Lesson 5. Software Orientation Tables are designed to organize data in columns and rows, as shown at right. The Table Tools Design.
Dept. of CSIE, National University of Tainan 10/21/2012 Arranging Components on a User Interface.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 5 1 Microsoft Office FrontPage 2003 Tutorial 5 – Creating Tables and Frames.
Chapter 7 A First Look at GUI Applications Layout Managers.
Chapter 9: Graphical User Interfaces
Modern Programming Language Java
University of Central Florida COP 3330 Object Oriented Programming
Tim McKenna Layout Mangers in Java Tim McKenna
Chap 7. Building Java Graphical User Interfaces
Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers.
Graphical User Interfaces -- Introduction
Timer class and inner classes
Containers and Components
Tim McKenna Layout Mangers in Java Tim McKenna
Creating Graphical User Interfaces
Panels & Layout Managers
Layout Organization and Management
Presentation transcript:

Layout Managers A layout manager is an object that determines the way that components are arranged in a container There are several predefined layout managers defined in the Java standard class library: 6-1 Defined in the AWT Defined in Swing Flow Layout Border Layout Card Layout Grid Layout GridBag Layout Box Layout Overlay Layout

6-2 Layout Managers Every container has a default layout manager, but we can explicitly set the layout manager as well Each layout manager has its own particular rules governing how the components will be arranged Some layout managers pay attention to a component's preferred size or alignment, while others do not A layout manager attempts to adjust the layout as components are added and as containers are resized

6-3 Layout Managers We can use the setLayout method of a container to change its layout manager JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); The following example uses a tabbed pane, a container which permits one of several panes to be selected See LayoutDemo.java LayoutDemo.java See IntroPanel.java IntroPanel.java

6-4 Flow Layout Flow layout puts as many components as possible on a row, then moves to the next row Rows are created as needed to accommodate all of the components Components are displayed in the order they are added to the container Each row of components is centered horizontally in the window by default, but could also be aligned left or right Also, the horizontal and vertical gaps between the components can be explicitly set See FlowPanel.java FlowPanel.java

6-5 Border Layout A border layout defines five areas into which components can be added North South CenterEastWest

6-6 Border Layout Each area displays one component (which could be a container such as a JPanel ) Each of the four outer areas enlarges as needed to accommodate the component added to it If nothing is added to the outer areas, they take up no space and other areas expand to fill the void The center area expands to fill space as needed See BorderPanel.java BorderPanel.java

6-7 Grid Layout A grid layout presents a container’s components in a rectangular grid of rows and columns One component is placed in each cell of the grid, and all cells have the same size As components are added to the container, they fill the grid from left-to-right and top-to-bottom (by default) The size of each cell is determined by the overall size of the container See GridPanel.java GridPanel.java

6-8 Box Layout A box layout organizes components horizontally (in one row) or vertically (in one column) Components are placed top-to-bottom or left- to-right in the order in which they are added to the container By combining multiple containers using box layout, many different configurations can be created Multiple containers with box layouts are often preferred to one container that uses the more complicated gridbag layout manager

6-9 Box Layout Invisible components can be added to a box layout container to take up space between components – Rigid areas have a fixed size – Glue specifies where excess space should go A rigid area is created using the createRigidArea method of the Box class Glue is created using the createHorizontalGlue or createVerticalGlue methods See BoxPanel.java BoxPanel.java

6-10 Borders A border can be put around any Swing component to define how the edges of the component should be drawn Borders can be used effectively to group components visually The BorderFactory class contains several static methods for creating border objects A border is applied to a component using the setBorder method

6-11 Borders An empty border – buffers the space around the edge of a component – otherwise has no visual effect A line border – surrounds the component with a simple line – the line's color and thickness can be specified An etched border – creates the effect of an etched groove around a component – uses colors for the highlight and shadow

6-12 Borders A bevel border – can be raised or lowered – uses colors for the outer and inner highlights and shadows A titled border – places a title on or around the border – the title can be oriented in many ways A matte border – specifies the sizes of the top, left, bottom, and right edges of the border separately – uses either a solid color or an image

6-13 Borders A compound border – is a combination of two borders – one or both of the borders can be a compound border See BorderDemo.java BorderDemo.java