Provision for GUIs in Java

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Graphical User Interfaces
Java Software Development Paradigm Lecture # 12. Basics of GUI.
Graphic User Interfaces Layout Managers Event Handling.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
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.
Java Swing Toolkit Graphics The key to effectively using graphics in Java is understanding: –the basic components of the graphics library –the patterns.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
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.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
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,
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,
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
עקרונות תכנות מונחה עצמים תרגול 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.
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.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
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.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
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.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
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.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
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.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
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.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
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.
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.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
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:
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
A Quick Java Swing Tutorial
Welcome To java
Provision for GUIs in Java
A First Look at GUI Applications
University of Central Florida COP 3330 Object Oriented Programming
Java GUI.
Lecture 27 Creating Custom GUIs
A Quick Java Swing Tutorial
Event Driven Programming and Graphical User Interface
GUIS: Graphical User Interfaces
תכנות מכוון עצמים בשפת JAVA
Steps to Creating a GUI Interface
A Quick Java Swing Tutorial
Introduction to Graphical Interfaces in Java: AWT and Swing
Graphical User Interface
Presentation transcript:

Provision for GUIs in Java CSC 202

Evolution of GUI Capabilities in Java

Java 1.0 Abstract Window Toolkit (AWT) Called “Abominable” or “Awful Window Toolkit”. Done in 30 days. Last minute add-on. Java 1.1 Significantly improved, But GUI not finished.

Java 2 - Swing Much improved from AWT. Part of Java Foundation Classes (JFC). Very easy to add: Accelerators Tool Tips Graphics Pluggable look and feel.

AWT vs Swing AWT approach Swing approach Implement common elements of various operating environments. Swing approach Departure from AWT effort. Swing only needs to know how to write a pixel on a screen in a particular environment. AWT classes are extended in Swing. Example: AWT Button became Swing JButton.

The Operating System GUI Interface

Multitask operating system (Windows, UNIX, Linux, etc.) When the o.s. detects an event such as a mouse click, It determines what the event was; It determines in which application window it occurred.

Operating System Interface The operating system Passes event info as a message to the appropriate application, and Permits the app to take action. May interrupt the subsequent action if another event is detected.

Java Containment Hierarchy - 1 One and only one top-level container. May contain any number of intermediate-level and atomic components. Swing: almost always a Jframe (see Fig. 12.1, Table 12.2) See MyFrame.java (Listing 12.1) Note the method calls.

Containment Hierarchy - 2 Next important level: “content pane.” Internal component of the top-level container. All visible components other than menu bar go here. (See Listing 12.2). Lower levels (lightweight components) See Figure 12.1.

Creation of a Basic GUI Create a frame. Add components. Instantiate a frame object. Establish characteristics of the frame. Example: MyFrame.java (Listing 12.1) Add components. Example: MyFrameWithComponents.java (Listing 12.2)

Layout Managers Each top-level and intermediate container has a default layout manager. JFrame, JDialog, and JPanel – BorderLayout JWindow – FlowLayout Defines how components are sized and positioned within the container's content pane. (See pp. 411-417, 8th ed.; pp. 451-458, 9th ed.)

Creating a Swing-Based Window - Two Approaches: Construct a GUI object using Swing components from within a main() method without first creating a separate GUI class. Sometimes used to introduce Swing components and to create extremely simple GUIs. This is how our first example was done. (See FirstGUI.java) Construct the GUI as a separate class using Swing components. (See FirstWindow.java) In general this is preferred (adheres more closely to accepted OO practice).

Reading Chapter 12 – Introduction to GUIs Chapter 13 – Reference Chapter 16 – Read to understand how to handle event-driven programming.