Advanced GUIs II CS 102-02 Lecture 9-1 1.

Slides:



Advertisements
Similar presentations
1 Graphical User Interface (GUI) Applications Abstract Windowing Toolkit (AWT) Events Handling Applets.
Advertisements

Graphical User Interfaces
AWT Components. 2 Using AWT Components 4 Component –Canvas –Scrollbar –Button –Checkbox –Label –List –Choice –TextComponent –TextArea –TextField 4 Component.
CS18000: Problem Solving and Object-Oriented Programming.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
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.
More Advanced AWT Last week, you learned about Applets, Lists, and Buttons AWT provides several other “widgets” and tools: –Labels –Choice boxes –Check.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 9 Object Oriented Programming in Java Advanced Topics Abstract Windowing.
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 lecture 12Lecture 13 Event Handling (cont.) Overview  Handling Window Events.  Event Adapters Revisited.  Introduction to Components and Containers.
CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
1 L46 Advanced GUI Component (1). 2 OBJECTIVES  To create and manipulate sliders, and menus,
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.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Graphical User Interface CSI 1101 N. El Kadri. Plan - agenda Graphical components Model-View-Controller Observer/Observable.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
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.
More Event Handling Adapters Anonymous Listeners Pop menus Validating User Input.
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.
Copyright © 2002, Systems and Computer Engineering, Carleton University Gui1.ppt * Object-Oriented Software Development Part 18 Building.
Abstract Window Toolkit (AWT) The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include:  A rich set.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
Session 10 CannonGame and Event-driven Programming.
1 Java Swing - Lecture 2 Components and Containment Boriana Koleva
Object Oriented Programming Engr. M. Fahad Khan Lecturer, Software Engineering Department University of Engineering & Technology, Taxila.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
9.1 Java Packages A collection of classes Allows classes to be grouped arbitrarily Hierarchical structure independent of inheritance Classes can.
Anonymous Classes An anonymous class is a local class that does not have a name. An anonymous class allows an object to be created using an expression.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
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.
Chapter 14- More Swing, Better looking applications.
CSI 3125, Preliminaries, page 1 Event Handling. CSI 3125, Preliminaries, page 2 Event Handling An Event Change in the state of an object is known as event.
1 IM103 week 8 (C&K ch17, p412) Advanced graphic programming Learning objectives By the end of this chapter you should be able to:  create dialogue windows.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Graphical User Interface (GUI)
Sep 181 Example Program DemoTranslateEnglishGUI.java.
IB103 Week 9 Free Standing Programs Chapter 18. Applets vs. Applications Applications are free standing See Program “Greeting” which prints out Hello.
Java Programming (By Rama Bhadra Rao M) You can Trace me in Day 5
Module 13: Swing API Object Oriented Programming(Java)
CSC 205 Programming II Lecture 5 AWT - I.
GUI building with the AWT
Object-Orientated Analysis, Design and Programming
Advanced GUIs II CS Lecture
Java Swing.
Abstract Window ToolKit (AWT)
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Event-driven programming for GUI
AWT Components and Containers
Steps to Creating a GUI Interface
Chapter 10 Getting Started with Graphics Programming
Constructors, GUI’s(Using Swing) and ActionListner
Programming Graphical User Interface (GUI)
11.1 Applets & graphics.
AWT Components Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavyweight i.e.
Advanced GUIs and Graphics
Presentation transcript:

Advanced GUIs II CS 102-02 Lecture 9-1 1

Agenda Scrollbars Frames and applications Popup menus Layout managers CardLayout GridBagLayout

Scrollbars Use Scrollbars two ways: Add scrollbars to components Use standalone as "sliders" Scrollbar objects are Components which implement Adjustable interface For objects with adjustable numeric value contained within a bounded range

What Scrollbars Need to Know Minimum value Maximum Horizontal or vertical orientation Delta for blocks and units Proportion viewed at one time

Scrollbar Tips Visible amount scroll bar is portion of total visible at one time Scrollbar's value can't exceed max minus scroll box size: minimum <= adjustableValue <= maximum - visible

Frames Applets run within a host application Other Containers Host provides the window Applets are Panels, which are Containers\ Other Containers ScrollPane Window Frame IS-A Window Frame = Window title + border

Frames are Handy to Have Use Frames to build standalone GUI applications Applets can use Frames too (pops up a new window)

Frame Tips Frames don't display by default Call the Frame object's setVisible() method with a true argument Frames don't have a default size Better call setSize() on the Frame object Default layout is BorderLayout Windows have events, which Frames inherit

Window Events Windows implement WindowListener windowActivated(WindowEvent) Invoked when a window is activated. windowClosed(WindowEvent) Invoked when a window has been closed. windowClosing(WindowEvent) Invoked when a window is in the process of being closed. windowDeactivated(WindowEvent) Invoked when a window is de-activated. windowDeiconified(WindowEvent) Invoked when a window is de-iconified. windowIconified(WindowEvent) Invoked when a window is iconified. windowOpened(WindowEvent) Invoked when a window has been opened.

Double-Duty: Applets and Applications Applications are similar to Applets, but have a main() method (like C & C++) Applications don't have a host window, so create one

Building Your Own Browser Write an applet which has a main() main() creates a host window (a Frame) Invokes the Applet inside the newly created Frame

Example of Appletication // Allow this applet to run as an application also public static void main( String args[] ) { // create application Frame and resize Frame app = new Frame( "Application" ); app.setSize( 300, 100 ); // register window handler to terminate application app.addWindowListener( new CloseWindowAndExit() ); // create applet instance MyFrame m = new MyFrame(); // initialize and start the applet m.init(); m.start(); // add applet to center of Frame app.add( m, BorderLayout.CENTER ); // display the frame (everything attached is painted) app.setVisible( true ); }

What's on the Menu? Applets don't have menus, because they don't have menu bars Frames can have menu bars Menus are: Good because they "clean up" the interface and unclutter it Bad because they often hide much functionality

Menus in Java Menu bar is the thingie that menus drop down from Menu item is a string inside a menu that causes an action to be performed when selected Action or another menu

Frames and Menus in Action Title bar MenuItem Menu Menubar

ScratchPad Application Lets users type text and change font and color Prevent typing by choosing read-only

Dialogs Dialogs are Windows with titles Common for passing information to user Two kinds Modal: Can't escape Non-modal (or modeless): Can be ignored

Popup Menus Popup menus can be attached to any Component (works for applets too!) Different platforms have different popup menu gestures When the AWT detects that a mouse event is the popup trigger event, it tags the event (remember MouseEvent.isPopupTrigger()?)

Layout Managers More layout managers CardLayout: "Stacks" several layouts on top of one another GridBagLayout: Like GridLayout, but more flexible (read more complex)