CSI 3125, Preliminaries, page 1 Layout Managers. CSI 3125, Preliminaries, page 2 Layout Managers The LayoutManagers are used to arrange components in.

Slides:



Advertisements
Similar presentations
GUI Elements Session 17. Memory Upload Layout Components Button TextField TextArea Label Choice Containers Panels The applet itself.
Advertisements

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.
CE203 - Application Programming Autumn 2013CE203 Part 71 Part 7.
Graphical User Interfaces
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.
Corresponds with Chapter 12
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
GUI programming AWT(Abstract Windows Toolkit)-GUI components library when Java was introduced AWT was replaced by Swing components import javax.swing.*;
Unit 131 GUI Layout Managers Learning Outcomes oList and distinguish between the four most common, standard layout managers in Java. oUse these and other.
LAB SESSION 10 *LAYOUT MANAGER *LISTENERS. Laying the components manually by using a null layout is tedious. Each container object has a layout manager.
IEEM 110 Computing in Industrial Applications Basic User Interface in Java.
Jan Containers Yangjun Chen Dept. Business Computing University of Winnipeg.
CS102--Object Oriented Programming Lecture 19: – The Swing Package (II) Copyright © 2008 Xiaoyan Li.
Layout Mangers CSC 171 FALL 2001 LECTURE 14. History: The Transistor William Shockley, John Bardeen, and Walter Brattain invent the transfer resistance.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
Advanced Java and Android Programming Day 1: Introduction to GUI Programming Intro to GUI Programming1.
OOP (Java): Layout/ OOP Objectives – –describe the basic layout managers for GUIs Semester 2, GUI Layout.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Graphical User Interface CSI 1101 N. El Kadri. Plan - agenda Graphical components Model-View-Controller Observer/Observable.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 12.
1 Why layout managers Can we perform layout without them? –Yes. A container’s layout property can be set to null. Absolute positioning: specify size and.
10/24/20151 Java GUI Programming. 10/24/20152 What is a GUI? Java has standard packages for creating custom Graphical User Interfaces Some of the fundamental.
Universidad Nacional de Colombia Facultad de Ingeniería Departamento de Sistemas ertificación en AVA.
CompSci 100E 35.1 Graphical User Interfaces: GUIs  Components  Flat Layouts  Hierarchical Layouts  Designing a GUI  Coding a GUI.
Object Oriented programming Instructor: Dr. Essam H. Houssein.
Layout Managers Arranges and lays out the GUI components on a container.
Layout Manager Summary
© 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.
Using AWT Controls, Layout Managers, and Menus Controls are components that allow a user to interact with your application in various ways A layout manager.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
Csc Basic Graphical User Interface (GUI) Components.
Computer Science 209 GUIs Model/View/Controller Layouts.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 14 : Swing II King Fahd University of Petroleum & Minerals College of Computer Science.
J McQuillanSE204:2004/2005: Lecture 3Slide 1 Specialised Components Can create specialised components. Do this by subclassing the component that you are.
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.
Lab 4: GUIs, Panels, Mouse and Key Listeners ICOM4015: FALL 2014 A N I NTRODUCTION TO P ANELS AND L AYOUTS CREATED BY KATYA I. BORGOS REVISED BY AMIR H.
March R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Project Proposals: Due Today!Project Proposals: Due Today! –Identify.
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
Graphical User Interface (GUI) Two-Dimensional Graphical Shapes.
Java Layouts CSIS 3701: Advanced Object Oriented Programming.
Java Swing - Lecture 3 Layout Management
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.
Dept. of CSIE, National University of Tainan 10/21/2012 Arranging Components on a User Interface.
AWT AWT stands for Abstract Windowing Toolkit. It contains all classes to write the program that interface between the user and different windowing toolkits.
GUI.1 Graphical User Interfaces GUIs. GUI.2 The Plan Components Flat Layouts Hierarchical Layouts Designing a GUI Coding a GUI.
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.
Graphical User Interfaces -- GUIs
Swing JComponents.
GUIs Model/View/Controller Layouts
Modern Programming Language Java
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
Containers and Components
Tim McKenna Layout Mangers in Java Tim McKenna
Creating Graphical User Interfaces
Panels & Layout Managers
GUI building with the AWT
LayoutManagers The LayoutManagers are used to arrange components in a particular manner. LayoutManager is an interface that is implemented by all the classes.
GUI building with the AWT
Advanced GUIs and Graphics
Presentation transcript:

CSI 3125, Preliminaries, page 1 Layout Managers

CSI 3125, Preliminaries, page 2 Layout Managers The LayoutManagers are used to arrange components in a particular manner. Layout Managers used to define the location and size of Graphical User Interface components. setLayout() – to set the layout

CSI 3125, Preliminaries, page 3 Layout Managers AWT has different Layout Managers classes FlowLayout GridLayout BorderLayout

CSI 3125, Preliminaries, page 4 Flow Layout The FlowLayout is used to arrange the components in a line, one after another (in a flow). It is the default layout of Applet. Here are the constructors for FlowLayout: FlowLayout( ) FlowLayout(int how) FlowLayout(int how, int horz, int vert) The first form creates the default layout, with centered alignment and a default 5 unit horizontal and vertical gap. The second form lets you specify how each line is aligned. Valid values for how are as follows: FlowLayout.LEFT or 0 FlowLayout.CENTER or 1 FlowLayout.RIGHT or 2 The third form allows you to specify the horizontal and vertical space left between components in horz and vert, respectively.

CSI 3125, Preliminaries, page 5 Flow Layout Prog import java.applet.Applet; import java.awt.*; /* */ public class Button1 extends Applet{ public void init(){ setLayout(new FlowLayout(FlowLayout.RIGHT)); //setLayout(new FlowLayout(FlowLayout.RIGHT,100,20)); Button b1=new Button("button1"); Button b2=new Button("button2"); Button b3=new Button("button3"); add(b1); add(b2); add(b3); }}

CSI 3125, Preliminaries, page 6 BorderLayout The BorderLayout class implements a common layout style for top-level windows. It has four narrow, fixed-width components at the edges and one large area in the center. The four sides are referred to as north, south, east, and west. The middle area is called the center. constructors defined by BorderLayout: BorderLayout( ) BorderLayout(int horz, int vert)

CSI 3125, Preliminaries, page 7 BorderLayout BorderLayout defines the following constants that specify the regions: BorderLayout.CENTER BorderLayout.SOUTH BorderLayout.EAST BorderLayout.WEST BorderLayout.NORTH When adding components, will use these constants with the following form of add( ) void add(Component compObj, Object region); It give more preference to CENTER when not specified

CSI 3125, Preliminaries, page 8 BorderLayout Prog import java.applet.Applet; import java.awt.*; /* */ public class border extends Applet{ public void init(){ setLayout(new BorderLayout()); Button b1=new Button("button1"); Button b2=new Button("button2"); Button b3=new Button("button3"); Button b4=new Button("button4"); Button b5=new Button("button5"); add(b1,BorderLayout.CENTER); add(b2,BorderLayout.SOUTH); add(b3,BorderLayout.EAST); add(b4,BorderLayout.WEST); add(b5,BorderLayout.NORTH); } //Centre higher priority

CSI 3125, Preliminaries, page 9 GridLayout The GridLayout is used to arrange the components in rectangular grid. define the number of rows and columns Constructors GridLayout( ) GridLayout(int numRows, int numColumns ) GridLayout(int numRows, int numColumns, int horz, int vert) The first form creates a single-column grid layout. The second form creates a grid layout with the specified number of rows and columns. The third form allows you to specify the horizontal and vertical space left between components in horz and vert, respectively.

CSI 3125, Preliminaries, page 10 GridLayout import java.applet.Applet; import java.awt.*; /* */ public class grid extends Applet{ String s; public void init(){ setLayout(new GridLayout(2,2)); //setLayout(new GridLayout()); Button b1=new Button("button1"); Button b2=new Button("button2"); Button b3=new Button("button3"); Button b4=new Button("button4"); Button b5=new Button("button5"); add(b1); add(b2); add(b3); add(b4); add(b5); }}

CSI 3125, Preliminaries, page 11 Layout Managers

CSI 3125, Preliminaries, page 12 Layout Managers

CSI 3125, Preliminaries, page 13 CardLayout The CardLayout class manages the components in such a manner that only one component is visible at a time. It treats each component as a card that is why it is known as CardLayout.

CSI 3125, Preliminaries, page 14 CardLayout constructors: CardLayout( ) CardLayout(int horz, int vert) The first form creates a default card layout. The second form allows you to specify the horizontal and vertical space left between components in horz and vert, respectively.

CSI 3125, Preliminaries, page 15 CardLayout prog import java.applet.Applet; import java.awt.*; /* */ public class card extends Applet{ String s; public void init(){ CardLayout ca = new CardLayout(); Panel p = new Panel(); p.setLayout(ca); Button b1=new Button("button1"); Button b2=new Button("button2"); Button b3=new Button("button3"); Button b4=new Button("button4"); Button b5=new Button("button5"); add(b1); add(b2); add(b3); add(b4); add(b5); }}