CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.

Slides:



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

15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Graphical User Interfaces (Part IV)
Drawing in a frame – Java GUI
CS18000: Problem Solving and Object-Oriented Programming.
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Graphic User Interfaces Layout Managers Event Handling.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
GUI and Event-Driven Programming Recitation – 3/6/2009 CS 180 Department of Computer Science, Purdue University.
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.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
Building Graphical User Interfaces Overview Constructing GUIs Interface components GUI layout Event handling Objects First with Java - A Practical.
Scott Grissom, copyright 2006Ch 11: GUI Slide 1 Graphical User Interfaces (Ch 11) Careful design of a graphical user interface is key to a viable software.
GUI and Event-Driven Programming Part 2. Event Handling An action involving a GUI object, such as clicking a button, is called an event. The mechanism.
CPSC150 JavaLynn Lambert CPSC150 Week 12 InheritanceInterfaces.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
More on Creating GUIs in Java using Swing David Meredith Aalborg University.
Java Swing. Introduction to Swing A GUI (graphical user interface) is a windowing system that interacts with the user The Java AWT (Abstract Window Toolkit)
CC1007NI: Further Programming Week 5 Dhruba Sen Module Leader (Islington College)
Java Programming Chapter 10 Graphical User Interfaces.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Java GUIs and Graphics CNS Outline  Introduction  Events  Components  Layout managers  Drawing  Introduction  Events  Components  Layout.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
OOP (Java): GUI Intro/ OOP Objectives – –use an image viewer application to introduce Java's GUI features Semester 2,
Programming with Java’s Swing API February 4, 2003 CMPS Advanced Programming Graphical User Interfaces.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
Field Trip #22 Creating an Excel Spreadsheet with Java By Keith Lynn.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Objects First With Java A Practical Introduction Using BlueJ Building Graphical User Interfaces 2.0.
1 Chapter 16: Creating Windows. 2 Basics of GUI Programming How to create a Window. TryWindow.java You always need a JFrame component before creating.
Building Graphical User Interfaces Overview Constructing GUIs Interface components GUI layout Event handling Objects First with Java - A Practical.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
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.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Objects First With Java A Practical Introduction Using BlueJ Building Graphical User Interfaces (GUIs) Week
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
Building Graphical User Interfaces Overview Constructing GUIs Interface components GUI layout Event handling © 2017 Pearson Education, Inc. Hoboken,
A Quick Java Swing Tutorial
Graphical User Interfaces
Advanced User Interfaces
A Quick Java Swing Tutorial
Building Graphical User Interfaces
Ellen Walker Hiram College
Event-driven programming for GUI
COS 260 DAY 23 Tony Gauvin.
COS 260 DAY 23 Tony Gauvin.
Graphical User Interface
Steps to Creating a GUI Interface
1 Graphical User Interfaces
A Quick Java Swing Tutorial
Graphical User Interface
Presentation transcript:

CS1054: Lecture 21 - Graphical User Interface

Graphical User Interfaces vs. Text User Interface

Three steps to GUI Programming What kind of elements can we show on screen? Components How do we arrange those elements? Layout How do we react to user input? Event Handlers

AWT vs SWING Java has two GUI libraries – AWT and Swing Swing later and much improved than AWT Equivalent classes in Swing can be identified by a J at the start of class name.

Top level Window In control of Operating System’s window management Java word – Frames Swing calls - JFrame

JFrame Windows Title bar Menu bar Content pane

Adding Simple Components JLabel frame.pack( ); frame.setVisible (true);

Adding Menus JMenuBar JMenu JMenuItem

Creating Menubars – 3 steps JMenuBar menubar = new JMenuBar ( ); frame.setJMenuBar ( menubar ); JMenu fileMenu = new JMenu ( “File”); menubar.add (fileMenu); JMenuItem openItem = new JMenuItem (“Open”); fileMenu.add (openItem); JMenuItem quitItem = new JMenuItem (“Quit”); fileMenu.add (quitItem);

Event Handling ActionEvent MouseEvent WindowEvent

To receive events 1. import java.awt.event.*; 2. To class header ActionListener interface 3. public void actionPerformed (ActionEvent event) 4. The objects must call addActionListener ( ) to register as a listener

Add ActionListener public class ImageViewer implements ActionListener public void actionPerformed (ActionEvent event) { System.out.println ("Item: " + event.getActionCommand ( )); } openItem.addActionListener( this); quitItem.addActionListener( this);

Layout Managers - Arrange components on a screen. - Each container has a Layout Manager associated with it. - The Layout Manager takes care of arranging components within that container

Layout Managers iswing/layout/visual.html -FlowLayout - BorderLayout - GridLayout

MouseListener Demo /java/awt/event/MouseListener.html