Panels & 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

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.
GridLayout, n*m grid. Column width/row height adjusted to fith the widest/highest Component.
CE203 - Application Programming Autumn 2013CE203 Part 71 Part 7.
Graphical User Interfaces
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.
Java Swing Recitation – 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University.
Eric Stokes, Matt Behling. GridbagLayout CardLayout SpringLayout.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
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.
GUI and Event-Driven Programming Recitation – 3/6/2009 CS 180 Department of Computer Science, Purdue University.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
OOP (Java): Layout/ OOP Objectives – –describe the basic layout managers for GUIs Semester 2, GUI Layout.
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.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 12.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
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.
Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight.
Layout Manager Summary
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
Layout Managers CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
University of Limerick1 Software Architecture Java Layout Managers.
Object-Oriented Software Engineering
3461 Laying Out Components Interior Design for GUIs.
Computer Science 209 GUIs Model/View/Controller Layouts.
CPSC 233 Tutorial Xin Apr 6, Reading files An example available on my website pages.cpsc.ucalgary.ca/~liuxin.
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.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
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.
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
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 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.
Session 10. Java Simplified / Session 10 / 2 of 36  An Applet is a Java program that can be executed with the help of a Java enabled browser.  Every.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Dept. of CSIE, National University of Tainan 10/21/2012 Arranging Components on a User Interface.
GUI Programming In Java Sagun Dhakhwa BIM, HSM. GUI Appllications Event Driven OOP Uses objects of Classes like in any other Java programming.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
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.
Object-Oriented Software Engineering JFrames with Swing.
Chapter 5 Patterns and GUI Programming -Part 2-. STRATEGY Pattern Layout Managers What if we need to specifies pixel position of components when  User.
Swing JComponents.
Advanced GUI Programming
GUIs Model/View/Controller Layouts
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
Chapter 7-3 (Book Chapter 14)
Steps to Creating a GUI Interface
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.
Layout Organization and Management
Presentation transcript:

Panels & Layout Managers 28 Panels & Layout Managers

Previously Coursework Support

Overview Panels & Layout Manager Positioning Elements Some of the Layout Managers Using Layout Managers Layout Manager Sample

Positioning Elements Layout Managers determines the size and position of the components within a container Layout manager has the final say on the size and position of the components within the container A layout manager is an object that implements the LayoutManager interface Common containers of interest are JPanel and Content Panes

Some of the Layout Managers BorderLayout Places components in up to five areas: top, bottom, left, right, and centre BoxLayout Places components in a single row or column CardLayout Used to display just one element from a list of components at a time add(Component, int) add(Component) add(Component, String)

Some of the Layout Managers FlowLayout Places components in a single row, starting a new row if its container is not sufficiently wide. It is the default Layout Manager for JPanel GridBagLayout Places components within a grid of cells, allowing components to span more than one cell GridLayout Places components in a grid of cells where each cell is exactly the same size and each component takes all the available space within its cell add(Component) add(Component, GridBagConstraints) add(Component)

Some of the Layout Managers GroupLayout with the horizontal and vertical layouts separately SpringLayout allows to specify relationships between the edges of components under its control GroupLayout and SpringLayout were developed for use by GUI builder tools

Using Layout Managers Methods to use Create Layout Manager Set the Layout Manager in the Container setLayout() Add Components into the Container add(…)

Lets code with a BorderLayout! Layout Manager Sample Lets code with a BorderLayout!

Layout Manager Sample JPanel mainView = new JPanel(new BorderLayout()); JButton jb1 = new JButton("Button 1 (PAGE_START)"); JButton jb2 = new JButton("Button 2 (CENTER)"); JButton jb3 = new JButton("Button 3 (LINE_START)"); JButton jb4 = new JButton("Button 4 (PAGE_END)"); JButton jb5 = new JButton("5 (LINE_START)"); setContentPane(mainView); mainView.add(jb1, BorderLayout.PAGE_START); mainView.add(jb2, BorderLayout.CENTER); mainView.add(jb3, BorderLayout.LINE_START); mainView.add(jb4, BorderLayout.PAGE_END); mainView.add(jb5, BorderLayout.LINE_END);

References A Visual Guide to Layout Managers Using Layout Managers http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html#card Using Layout Managers http://download.oracle.com/javase/tutorial/uiswing/layout/using.html