Layout Organization and Management

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.
TCU CoSc Programming with Java Visual Design (Chapter 5)
Java Software Development Paradigm Lecture # 12. Basics of GUI.
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.
Advanced Swing. Advanced Layout Managers GridBagLayout – Example: Web Browser (Grid Bag Layout)Web Browser (Grid Bag Layout) BoxLayout – Example: Web.
Corresponds with Chapter 12
CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5.
GUI programming AWT(Abstract Windows Toolkit)-GUI components library when Java was introduced AWT was replaced by Swing components import javax.swing.*;
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Unit 131 GUI Layout Managers Learning Outcomes oList and distinguish between the four most common, standard layout managers in Java. oUse these and other.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
LAB SESSION 10 *LAYOUT MANAGER *LISTENERS. Laying the components manually by using a null layout is tedious. Each container object has a layout manager.
1 L48 Advanced GUI Component (3). 2 OBJECTIVES  To use additional layout managers.
Jan Containers Yangjun Chen Dept. Business Computing University of Winnipeg.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
OOP (Java): Layout/ OOP Objectives – –describe the basic layout managers for GUIs Semester 2, GUI Layout.
Principles of Web Design 6 th Edition Chapter 7 – Page Layouts.
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.
Nov 061 Size Control How is a component’s size determined during layout and during resize operations? Three factors determine component sizes: The component’s.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 12.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Chapter 8: Getting Started with Graphics Programming Graphics Class Hierarchy Graphics Class Hierarchy Frames Frames The relationship between frame and.
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.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
Layout Managers Arranges and lays out the GUI components on a container.
Layout Manager Summary
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
© Marty Hall, Larry Brown, Web core programming 1 Layout Managers Arranging Elements in Windows.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
University of Limerick1 Software Architecture Java Layout Managers.
Object-Oriented Software Engineering
3461 Laying Out Components Interior Design for GUIs.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Layout How multiple components are composed to build interfaces.
CPSC 233 Tutorial Xin Apr 6, Reading files An example available on my website pages.cpsc.ucalgary.ca/~liuxin.
J McQuillanSE204:2004/2005: Lecture 3Slide 1 Specialised Components Can create specialised components. Do this by subclassing the component that you are.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
AWT Layout Managers (Chapter 10) Java Certification Study Group January 21, 1999 Mark Roth.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 3 Designing the Interface with Layout Managers.
CSI 3125, Preliminaries, page 1 Layout Managers. CSI 3125, Preliminaries, page 2 Layout Managers The LayoutManagers are used to arrange components in.
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
Java Layouts CSIS 3701: Advanced Object Oriented Programming.
Java Swing - Lecture 3 Layout Management
1 CSE 331 Composite Layouts; Decorators slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Event Handler Methods Text field Object Responder JAVA AWT Environment: Messages are sent between JAVA Objects Screen Event Notification Press Button.
User Interface Components. Layout Placement of UI components in a window – Size & Position Each component occupies a rectangular region in the window.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
Layouts To understand various layouts extjs provides, and overview of some commonly used layouts.
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 7 A First Look at GUI Applications Layout Managers.
Java FX: Scene Builder.
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.
Containers and Components
Tim McKenna Layout Mangers in Java Tim McKenna
Creating Graphical User Interfaces
Panels & Layout Managers
LayoutManagers The LayoutManagers are used to arrange components in a particular manner. LayoutManager is an interface that is implemented by all the classes.
GUI Layouts By: Leonard & Saif.
Presentation transcript:

Layout Organization and Management COSC 3461 S04 Module 4B Layout Organization and Management

Models for Component Layout Absolute (aka fixed) Control for component size and position Struts and springs Control for component position Variable intrinsic size Control for component size

Absolute Layout The principle is to specify the position and the size of each component provide absolute values (not relative) position is specified by x and y screen coordinates (typically in pixels, origin in top-left corner) size is specified by width and height values (typically in pixels)

Example DemoAbsolute.java

Absolute Layout Disadvantages Advantages Widgets retain their position and size when window is resized Enlarging: too much empty space (more in Module 6, Evaluation) Shrinking: components get lost (how might this instead be handled?) Difficult to modify layout; need to modify many ‘magic numbers’ Advantages Can be simple to specify layout

Struts and Springs Idea: specify relative position of components the specification is given in terms of constraints the constraints specify geometric relationships between the components and the borders of container the sizes and positions of the components are determined by layout manager the layout manager calculates the (x,y) coordinates and component sizes so that the specified constraints relationships are maintained, to the degree that is possible.

Struts and Springs Struts are regions of a fixed, inflexible size represented by Springs are regions that have a certain size initially, but can be compressed or stretched as needed Text Field Button

Struts and Springs Advantages When the window is resized, components will automatically be repositioned position is determined by layout manager’s solution to constraint equations Easy to use Handles window resizing appropriately

Variable Intrinsic Size Idea: specify intrinsic size values for widgets intrinsic means pertaining to the inherent or essential nature of a thing (cf extrinsic, originating from the outside, external) intrinsic values capture a range of acceptable values: preferred size, minimum size, maximum size let layout manager determine which size value should be used During layout, components report their size properties to the layout manager (recursively, if necessary) Designers have limited control over this Some layout managers respect size properties, while others do not!

Variable Intrinsic Size Advantages Layout manager determines appropriate values Disadvantages Designers have limited control over this Some layout managers respect size properties, while others do not!

Java’s Layout Managers BorderLayout* spec. purpose BoxLayout very flexible CardLayout spec. purpose FlowLayout** very simple GridBagLayout very simple GridLayout very simple SpringLayout very flexible * default layout manager of content pane ** default layout manager of JPanel

BorderLayout Places components in one of five regions North, South, East, West, Center all extra space is placed in center Support for struts and springs Struts (YES) Can specify ‘hgap’, ‘vgap’ Springs (NO) Inter-component space is fixed Support for variable intrinsic size (YES) Components expand to fill space in region

BorderLayout Components ‘expand’ (or ‘stretch’) to fill space as follows Expand direction North West Center East South

Example DemoBorderLayout.java usage: java DemoBorderLayout arg1 where 'arg1' = strut size in pixels Example (next 2 slides)

Example strut size=0 Invocation: java DemoBorderLayout 0 Launch Resize Variable intrinsic size

Example With struts : hgap = vgap = 10 pixels Invocation: java DemoBorderLayout 10 Launch Resize Struts

BoxLayout Components placed in a single row or column Alignment can be specified Components do not wrap Support for struts and springs Struts (YES) Can specify ‘rigid areas’ Springs (YES) Can specify ‘horizontal glue’ or ‘vertical glue’ Support for variable intrinsic size (YES) Components expand if maximum size property is set

Example DemoBoxLayout.java usage: java DemoBoxLayout arg1 arg2 where 'arg1' is one of c = centre alignment l = left alignment r = right alignment and 'arg2' is one of e = enable struts and springs demo d = disable struts and springs demo Example (next 2 slides)

Example Invocation: java DemoBoxLayout l d Invocation: java DemoBoxLayout r d Invocation: java DemoBoxLayout c d Default is left align

Enable struts and springs demo Example Enable struts and springs demo Invocation: java DemoBoxLayout c e Launch Resize Resize more Struts (10 pixels) Springs

FlowLayout Components are placed one after another, from left to right If container isn’t wide enough, a new row is started The group can be aligned: left, center, right Space is added before/after/below the entire group of components to fill available space Support for struts and springs Struts (YES) Can specify ‘hgap’, ‘vgap’ Springs (NO) Inter-component space is fixed Support for variable intrinsic size (NO) Component size is fixed

Example DemoFlowLayout.java usage: java DemoFlowLayout arg1 arg2 where 'arg1' = strut size in pixels and 'arg2' is one of c = center alignment l = left alignment r = right alignment Example (next 2 slides)

Example Default for FlowLayout… struts : hgap = vgap = 5, alignment = center Invocation: java DemoFlowLayout 5 c Launch Resize Fill available space before/after/below group of components

Example With struts : hgap = vgap = 10, alignment = right Invocation: java DemoFlowLayout 10 r Launch Resize

GridLayout A number of rows and columns are requested Components are arranged in the grid Components are made equal in size Support for struts and springs Struts (YES) Can specify ‘hgap’, ‘vgap’ Springs (NO) Inter-component space is fixed Support for variable intrinsic size (YES) Components expand to fill rectangle

Example DemoGridLayout.java usage: java DemoGridLayout arg1 where 'arg1' = strut size in pixels Example (next 2 slides)

Example No struts Invocation: java DemoGridLayout 0 Launch Resize Equal-size rectangles

Example With struts : hgap = vgap = 10 Invocation: java DemoGridLayout 10 Launch Resize