CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Corresponds with Chapter 12
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
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.
CS102--Object Oriented Programming Lecture 19: – The Swing Package (II) Copyright © 2008 Xiaoyan Li.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Java Programming Chapter 10 Graphical User Interfaces.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Introduction to HTML Part 3 Chapter 2. Learning Outcomes Identify how to design frames. Explain frames’ attributes. Describe the method on designing forms.
1. Chapter 10 Managing and Printing Documents 3 Working with Files and Printing You can open multiple documents in Word. When multiple documents are.
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.
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
Layout Manager Summary
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
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.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
University of Limerick1 Software Architecture Java Layout Managers.
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.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
Csc Basic Graphical User Interface (GUI) Components.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Creating User Interfaces Chapter 13 CSCI CSCI 1302 – Creating User Interfaces2 Outline Introduction Common Features of Swing GUI Components Buttons.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 14 : Swing II King Fahd University of Petroleum & Minerals College of Computer Science.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
HTML Creating Forms on a Web Page. 2 Objectives  Discuss the process of creating a form  Distinguish between data input controls and text input controls.
Graphical User Interfaces Tonga Institute of Higher Education.
AWT Layout Managers (Chapter 10) Java Certification Study Group January 21, 1999 Mark Roth.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Graphical User Interface (GUI)
Event Handler Methods Text field Object Responder JAVA AWT Environment: Messages are sent between JAVA Objects Screen Event Notification Press Button.
1 Lecture 8: User Interface Components with Swing.
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.
GUIs & Event-Driven Programming Chapter 11 Review.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Chapter 7 A First Look at GUI Applications Layout Managers.
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Modern Programming Language Java
Tim McKenna Layout Mangers in Java Tim McKenna
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Timer class and inner classes
Containers and Components
Tim McKenna Layout Mangers in Java Tim McKenna
Creating Graphical User Interfaces
Zhen Jiang West Chester University
Layout Organization and Management
Advanced GUIs and Graphics
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

CS221 © 2007 Ray S. Babcock Layout, Components, & Data Entry Appendix C.3-C.5

CS221 © 2007 Ray S. Babcock Layout Managers  BorderLayout  Arranges objects in five areas of the container.  FlowLayout  Arranges objects in left-to-right order.  BoxLayout  Arranges objects in a single row or column.  GridLayout  Arranges objects in a two-dimensional grid.  BorderLayout  Arranges objects in five areas of the container.  FlowLayout  Arranges objects in left-to-right order.  BoxLayout  Arranges objects in a single row or column.  GridLayout  Arranges objects in a two-dimensional grid.

CS221 © 2007 Ray S. Babcock BorderLayout  Default layout for JFrame’s content pane.  5 areas (N,S,E,W,Center)  Don’t have to fill out all areas.  See Listing and Example.  Be sure to use Java reference.  Java Reference Document Java Reference Document  Remember to look up class hierarchy.  Use Index.  Find setBorder?  Constants.  Default layout for JFrame’s content pane.  5 areas (N,S,E,W,Center)  Don’t have to fill out all areas.  See Listing and Example.  Be sure to use Java reference.  Java Reference Document Java Reference Document  Remember to look up class hierarchy.  Use Index.  Find setBorder?  Constants.

CS221 © 2007 Ray S. Babcock FlowLayout  Left to Right until maximum width.  Dimension for array size.  PreferredSize (20, 20).  Show resize of window.  Last line centered if not full.  Use setAlignment to change order.  See Listing and Example.  Left to Right until maximum width.  Dimension for array size.  PreferredSize (20, 20).  Show resize of window.  Last line centered if not full.  Use setAlignment to change order.  See Listing and Example.

CS221 © 2007 Ray S. Babcock BoxLayout  Horizontal or Vertical arrangement.  BoxLayout.X_AXIS  BozLayout.Y_AXIS  Components don’t wrap.  See Listing and Example.  What’s missing from this code?  (Hint: related to buttons.)  Horizontal or Vertical arrangement.  BoxLayout.X_AXIS  BozLayout.Y_AXIS  Components don’t wrap.  See Listing and Example.  What’s missing from this code?  (Hint: related to buttons.)

CS221 © 2007 Ray S. Babcock GridLayout  Rectangular grid.  Fixed Size (set by setLayout(new GridLayout( 5,10) )  5 rows and 10 columns.  See Listing and Example.  Note Integer.toString (conversion method)  Factories described on page 183.  Rectangular grid.  Fixed Size (set by setLayout(new GridLayout( 5,10) )  5 rows and 10 columns.  See Listing and Example.  Note Integer.toString (conversion method)  Factories described on page 183.

CS221 © 2007 Ray S. Babcock Combining Layouts  Lab #3 (Programming #2, page 785)

CS221 © 2007 Ray S. Babcock Components for Data Entry  So what does a good GUI do?  Enable the user to provide input data to an application.  Enable the user to control the action of the application.  Display information or results to the user.  Are there any “bad” Guis?  Web Pages That Suck Poor DesignPoor Design  Interface Hall Of Shame ShameShame  So what does a good GUI do?  Enable the user to provide input data to an application.  Enable the user to control the action of the application.  Display information or results to the user.  Are there any “bad” Guis?  Web Pages That Suck Poor DesignPoor Design  Interface Hall Of Shame ShameShame

CS221 © 2007 Ray S. Babcock CheckBoxDemo  Multiple selections possible.  Check mark shows selection.  See Listing and Example.  Note listeners.  Multiple selections possible.  Check mark shows selection.  See Listing and Example.  Note listeners.

CS221 © 2007 Ray S. Babcock RadioButtonDemo  Only one selection possible.  Old time “radio buttons”, press one and it resets the others.  See Listing and Example.  Note selections.length used to control number of buttons.  Also, note the loop to define buttons.  Only one selection possible.  Old time “radio buttons”, press one and it resets the others.  See Listing and Example.  Note selections.length used to control number of buttons.  Also, note the loop to define buttons.

CS221 © 2007 Ray S. Babcock ComboBoxDemo  Selections shown by text.  Drop-down list.  See Listing and Example  Note, no loop.  Selections shown by text.  Drop-down list.  See Listing and Example  Note, no loop.

CS221 © 2007 Ray S. Babcock TextFieldDemo  Label and field to type in.  See Listing and Example.  Note NumberEntered uses an exception.  Label and field to type in.  See Listing and Example.  Note NumberEntered uses an exception.

CS221 © 2007 Ray S. Babcock Example Data Entry in a GUI  VolumeConverterGUI  Fairly complicated constructor.  Enter in one field, output in the other.  Notice how the gui is built-up in layers.  JFrame’s content pane set to a 2x2 grid.  The grid contains labels and text boxes.  Two files to look at.  See Listing and Example.  VolumeConverterGUI  Fairly complicated constructor.  Enter in one field, output in the other.  Notice how the gui is built-up in layers.  JFrame’s content pane set to a 2x2 grid.  The grid contains labels and text boxes.  Two files to look at.  See Listing and Example.

CS221 © 2007 Ray S. Babcock CurrencyDemo  An example of querrying “where am I”?  Using the Java locale.  An example of querrying “where am I”?  Using the Java locale.