Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

JAVA API (GUI) Subject:T0934 / Multimedia Programming Foundation Session:1 Tahun:2009 Versi:1/0.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Introduction to GUI Programming
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
Unit 111 Java GUI Components and Events  Learning Outcomes oDistinguish between GUI components and containers. oIdentify and distinguish top-level containers.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Graphical User Interface (GUI) Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Java Swing Chris North cs3724: HCI. AWT to Swing AWT: Abstract Windowing Toolkit import java.awt.* Swing: new with Java2 import javax.swing.* Extends.
Chapter 8: Graphical User Interfaces Objectives - by the end of this chapter, you should be able to do the following: –write a simple graphical user interface.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
GUI Programming in Java
Java Programming Chapter 10 Graphical User Interfaces.
Software Construction Lecture 10 Frameworks
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
Applets and Frames CS 21a: Introduction to Computing I First Semester,
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.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
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.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
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.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
CS Lecture 00 Swing overview and introduction Lynda Thomas
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
CSCI Swing1 The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness –The Abstract.
Event Driven Programming. Event-driven Programming In the early days of computing communication with the outside world was accomplished using a technique.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
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.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise.
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 Swing One of the most important features of Java is its ability to draw graphics.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
1 Lecture 8: User Interface Components with Swing.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Java Swing What is swing? Swing is a ”Lightweight” GUI ToolKit for Java Different from AWT / SWT Toolkits for GUIs Few lines of code to produce GUI elements.
A Quick Java Swing Tutorial
Welcome To java
Provision for GUIs in Java
A First Look at GUI Applications
Java Swing.
Provision for GUIs in Java
Event Driven Programming and Graphical User Interface
Week 8 Swing NetBeans GUI Builder
Presentation transcript:

Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java GUI Library Evolution GUI Components and Containers Swing's Top-level Containers Learning Outcomes oExplain the motivation for, and usefulness of GUIs. oList and explain seven principles of good GUI design and their benefits. oDiscuss what GUI programming involves, and explain how Java's GUI library evolved.  Exercises

Unit 092 GUIs—Graphical User Interfaces In a text-based UI the commands are entered from the keyboard. In a console program, the system usually controls user actions. > Enter number of classes: 3 > Enter number of students: 15 > You have 45 students Most modern programs use a GUI (pronounced “gooey”): Graphical: Not just text or characters but windows, menus, buttons,.. User: Person using the program Interface: Way to interact with the program Graphical elements include: Window: Portion of screen that serves as a smaller screen within the screen Menu: List of alternatives offered to user Button: Looks like a button that can be pressed Text fields: The user can write something in

Unit 093 A New Approach to Programming Previous Style of Programming: List of instructions performed in order Next thing to happen is next thing in list Program performed by one agent— the computer Event-Driven Style of Programming: Objects that can fire events and objects that react to events Next thing to happen depends on next event Program is interaction between user and computer

Unit 094 Event-Driven Programming Programs with GUIs often use Event-Driven Programming A user interacts with the application by: –Clicking on a button to choose a program option. –Making a choice from a menu. –Entering text in a text field. –Dragging a scroll bar. –Clicking on a window's close button. Program waits for events to occur and then responds Firing an event: When an object generates an event Listener: Object that waits for events to occur Event handler: Method that responds to an event

Unit 095 Principles of GUI Design Give time for GUI design and integration. Have a simple and clear layout. Use graphics objects and terminology consistently. Be functionally intuitive and visually attractive. Provide visual and audible feedback. Be responsive. Be flexible and customizable.

Unit 096 Benefits of Good GUIs Facilitate higher user productivity and lower long-term costs. Improve integrity of underlying application. Improve the reliability and safety of mission-critical applications. Improve user confidence. Make software more marketable.

Unit 097 GUI Programming Issues What do I need to know to write good GUI applications? Writing GUI applications requires knowledge of: 1.Graphics 2.Media 3.Windows 4.Events 5.Multithreading

Unit 098 Three Parts of a GUI Program A GUI program consists of three types of software: 1.Graphical Components that make up the GUI. 2.Listener methods that receive the events and respond to them. 3.Application methods that do useful work for the user. In Java, you can get the GUI components you want by asking for them. Most of the work has already been done and is contained in the Swing/AWT packages. Swing/AWT contains windows, frames, buttons, menus and other components. You get graphical components by constructing Swing/AWT objects. Listener methods and application methods are Java methods that you write or invoke from JDK. To write a GUI application, keep the three types software separated (while keeping the big picture in mind).

Unit 099 Building a GUI Create: Frame/JFrame Panel/JPanel Components Listeners Add: Listeners into components Components into panel Panel into frame JPanel JButton Listener JFrame JLabel

Unit 0910 Using a GUI Component 1.Create it 2.Configure it 3.Add children (if container) 4.Add to parent (if not JFrame) 5.Add Listeners of events Order is importance

Unit 0911 Using a GUI Component 1.Create it Instantiate object: JButton b = new JButton(); 2.Configure it Methods: b.setText(“Press me”); 3.Add it panel.add(b); 4.Listen to it Events: Listeners Press me

Unit 0912 Application Code import javax.swing.*; class Hello { public static void main(String[] args){ JFrame f = new JFrame(“Hello World”); JPanel p = new JPanel(); JButton b = new JButton(“press me”); p.add(b);// add button to panel f.getContentPane().add(p); // add panel to frame f.show(); } press me

Unit 0913 Java GUI API Evolution Java provides classes representing UI items like windows, buttons, menus etc. The GUI toolkit in older versions of Java is called AWT. An enriched version the toolkit, Swing, was developed in later versions of Java. AWT and Swing are part of the Java Foundation Classes (JFC). Why was Swing developed in addition to AWT? Special library of classes that allows Java programs to have a windowing interface An improved version of older library called Abstract Window Toolkit (AWT). Standard part of all versions of Java 2 (JDK 1.2)

Unit 0914 Java GUI API Evolution (cont'd) AWT components: –Heavyweight components –Associated with native components called peers –Same behaviour, but platform-dependent look –Package java.awt By relying on native peers, AWT components are limited: Slow on some platforms. Portability problems. Swing components: –Lightweight components –Are rendered and controlled by the JVM. –Swing has more powerful options –Swing can be shipped with application as it is non-native. –Package javax.swing

Unit 0915 Swing is based on a composite design Top-Level Container –Example: JFrame –Holds all other swing components –Other options: JDialog and JApplet Intermediate Container –Example: JPanel –Used to control placement of GUI components –Acts as a middle person –Other options: JScrollPane, JTabbedPane, … Atomic Components –Example: JButton –Used for self-contained GUI components –Other options: JTextField, JTable, Swing Features and Concepts

Unit 0916 Containment hierarchy Top level containers: JFrame, JDialog, JApplet Basic controls: JButton, JComboBox, List, Menu, Slider, JTextField, JLabel, progress bar, tool tip Content pane: the main container in JApplet, JDialog, and JFrame Objects General purpose containers: Panel, scroll pane, split pane, tabbed pane, tool bar

Unit 0917 Review Exercises 1.Explain the advantages of graphics-based over text-based user interfaces. 2.What is a good and effective GUI? Why is it necessary to design GUI for all on-trivial applications? Explain.. 3.Explain the implications of good as well as badly designed GUIs. 4.What is JFC? What Swing? Why was the JFC enriched with Swing? 5.AWT components are said to be heavy weight while Swing components are said to be light weight. Explain what these notions mean. 6.Enumerate the major knowledge units that must be understood for developing effective GUI applications. Briefly explain each of these knowledge units.