1 L48 Advanced GUI Component (3). 2 OBJECTIVES  To use additional layout managers.

Slides:



Advertisements
Similar presentations
Chapter 3 – Web Design Tables & Page Layout
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.
Graphical User Interfaces
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.
 Pearson Education, Inc. All rights reserved GUI Components: Part 2.
LayoutManager, J 1 Layout Manager. LayoutManager, J 2 Layout Manager To each UI container there is a layout manager (an object). When you add a component.
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.
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.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
Using HTML to Create Tables in Web pages Connie Lindsey November 2005.
CHAPTER 11 Tables. How Are Tables Used Data Display  Very tidy and very useful Better Text Alignment  Putting text in tables allows you to format indents.
1 Chapter 22 Containers, Layout Managers, and Borders.
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.
WHAT are frames? what.html are.htmlframes.html. Intro to Frames HTML frames allow you to display more than 1 HTML document in the same browser window.
1 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 3 GEORGE KOUTSOGIANNAKIS George Koutsogiannakis / Summer 2011.
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.
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 7 Interfacing with Users.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
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.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
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.
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.
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.
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.
AGDER COLLEGEFACULTY OF ENGINEERING & SCIENCE GUI Components ikt403 – Object-Oriented Software Development.
3461 Laying Out Components Interior Design for GUIs.
Copyright Curt Hill GridBag Layout Manager A flexible but complicated layout.
Grid Bag Layout Most Complex and Powerful Components can vary in size and can be added in any order Draw out on piece of paper first Columns and Rows:
CPSC 233 Tutorial Xin Apr 6, Reading files An example available on my website pages.cpsc.ucalgary.ca/~liuxin.
Creating Tables LESSON 6 - #1.06 ESSENTIAL STANDARD #1 - UNDERSTAND WORD PROCESSING INDICATOR #6 – CREATING TABLES.
Key Applications Module Lesson 14 — Working with Tables Computer Literacy BASICS.
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.
Java Layouts CSIS 3701: Advanced Object Oriented Programming.
Java Swing - Lecture 3 Layout Management
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
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.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
GUI.1 Graphical User Interfaces GUIs. GUI.2 The Plan Components Flat Layouts Hierarchical Layouts Designing a GUI Coding a GUI.
Chapter 7 A First Look at GUI Applications Layout Managers.
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Modern Programming Language Java
University of Central Florida COP 3330 Object Oriented Programming
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.
Layout Organization and Management
Key Applications Module Lesson 14 — Working with Tables
Presentation transcript:

1 L48 Advanced GUI Component (3)

2 OBJECTIVES  To use additional layout managers.

Layout Managers: BoxLayout and GridBagLayout (Cont.) Vertical struts – Invisible GUI component that has a fixed pixel height Used to guarantee a fixed amount of space between GUI components static Box method createVerticalStrut – int argument determines the height of the strut in pixels Box also declares method createHorizontalStrut

Layout Managers: BoxLayout and GridBagLayout (Cont.) Horizontal glue – An invisible GUI component that occupies additional space between fixed-size GUI components When the container is resized, components separated by glue remain the same size, but the glue stretches or contracts to occupy the space between them – static Box methods createHorizontalGlue and createVerticalGlue

5 Outline BoxLayoutDemo.java (1 of 2) Arrows for cycling through tabs

6 Outline BoxLayoutDemo.java (2 of 2)

Layout Managers: BoxLayout and GridBagLayout (Cont.) Rigid areas – An invisible GUI component that always has a fixed pixel width and height Dimension object argument to static Box method createRigidArea specifies the area’s width and height

Layout Managers: BoxLayout and GridBagLayout (Cont.) GridBagLayout Layout Manager – Similar to GridLayout in that it arranges components in a grid, but more flexible The components can vary in size and can be added in any order – Determining the appearance of the GUI Draw the GUI on paper Draw a grid over it, dividing the components into rows and columns – The initial row and column numbers should be 0 – Used by the GridBagLayout layout manager to properly place the components in the grid

Layout Managers: BoxLayout and GridBagLayout (Cont.) GridBagConstraints object – Describes how a component is placed in a GridBagLayout – anchor specifies the relative position of the component in an area that it does not fill Constants: NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST and CENTER (the default) – fill defines how the component grows if the area in which it can be displayed is larger than the component Constants: NONE (the default), VERTICAL, HORIZONTAL and BOTH

Layout Managers: BoxLayout and GridBagLayout (Cont.) – gridx and gridy specify where the upper-left corner of the component is placed in the grid – gridwidth and gridheight specify the number of columns and rows a component occupies – weightx and weighty specify how to distribute extra horizontal and vertical space to grid slots in a GridBagLayout when the container is resized A zero value indicates that the grid slot does not grow in that dimension on its own – However, if the component spans a column/row containing a component with nonzero weight value, it will grow in the same proportion as the other components in that column/row Use positive nonzero weight values to prevent “huddling”

11 Fig | Designing a GUI that will use GridBagLayout. Column Row

12 Fig | GridBagConstraints fields.

13 Fig | GridBagLayout with the weights set to zero.

14 Outline GridBagFrame.java (1 of 3) Create a GridBagLayout object Create a GridBagConstraints object

15 Outline GridBagFrame.java (2 of 3) Cause the JTextArea to always fill its entire allocated area Call utility method addComponent with the JTextArea object, row, column and numbers of columns and rows to span as arguments When the window is resized, button2 will grow

16 Outline GridBagFrame.java (3 of 3) button3 will still grow because of the weight values of button2 Set constraints and add component

17 Outline GridBagDemo.java (1 of 2)

18 Outline GridBagDemo.java (2 of 2)

Layout Managers: BoxLayout and GridBagLayout (Cont.) GridBagConstraints constants – RELATIVE Specifies that the next-to-last component in a particular row should be placed to the right of the previous component in the row – REMAINDER Specifies that a component is the last component in a row – Components that are not the second-to-last or last component on a row must specify values for gridwidth and gridheight

20 Outline GridBagFrame2.java (1 of 3) Create a GridBagLayout object

21 Outline GridBagFrame2.java (2 of 3) Specify that the JTextField is the last component on the line Specify that the JButton is to be placed relative to the previous component This JButton is the last component on the line

22 Outline GridBagFrame2.java (3 of 3) The JComboBox is the only component on the line This JButton is the only component on the line This JButton is the next-to- last component on the line

23 Outline GridBagDemo2.java (1 of 2)

24 Outline GridBagDemo2.java (2 of 2)