The AWT Package, An Overview

Similar documents
(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI

Abstract Window Toolkit Overview

Sri Vidya College of Engineering & Technology

The AWT Package, Placing Components in Containers, CardLayout. Preface. Introduction

Java. GUI building with the AWT

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

The Java Programming Language Basics. Identifiers, Keywords, and Types. Expressions and Flow Control. Object-Oriented Programming. Objects and Classes

CHAPTER 2. Java Overview

Essential Series. Springer-Verlag London Ltd.

John Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer

Frameworks. CS151 Chris Pollett Oct. 26, 2005.

Java Application Development

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

CSC207H: Software Design Lecture 11

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Table of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...

Programming Mobile Devices J2SE GUI

Java Applets / Flash

CS 251 Intermediate Programming GUIs: Components and Layout

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

cs Java: lecture #5

Introduction to the JAVA UI classes Advanced HCI IAT351

The AWT Package, Graphics- Introduction to Images

ощ 'ршорвшэш! цвн-эориэу ощ 'sajbpossv # PIPG DUJ 'ssjmoossv ^ PIPG pipa w н OX ЛЮН VAV

GUI in Java TalentHome Solutions

Creating Rich GUIs in Java. Amy Fowler Staff Engineer JavaSoft

Laying Out Components. What is Widget Layout?

Swing from A to Z Some Simple Components. Preface

Educational Fusion. Implementing a Production Quality User Interface With JFC

7. Program Frameworks

Introduction to Java Programming

Graphical User Interfaces (GUIs)

Introduction p. 1 Java Features p. 2 Java Expansion p. 4 Getting, Setting Up, and Using Java p. 5 The Java Language p. 5 Java Swing Components p.

Introduction to Java Programming

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

Q1. What is the difference between an Abstract class and Interface? Q2.What are checked and unchecked exceptions?

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

CHAPTER 1: A GENERAL INTRODUCTION TO PROGRAMMING 1

1.0 Libraries Technical Overview

Java - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,

Java Programming Lecture 6

AWT GRAPHICS CLASS. Introduction. Class declaration. Class constructors. Class methods

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

Chapter 12 Advanced GUIs and Graphics

The AWT Component Library 10

Packages: Putting Classes Together

JAVA. A. Zakiuddin Ahmed. M.Sc.,M.Phil M.S.(Edn), PGDCSM, Professor in Computer Science, P. Rizwan Ahmed. MCA., M.Sc.,M.A., M.Phil.

Programming graphics

This page intentionally left blank

SCHEME OF COURSE WORK

Swing from A to Z Using Focus in Swing, Part 2. Preface

The Big Three of the AWT on page 327. Two Types of Layout Managers on page 331. Layout Managers and Container Insets on page 332

1. Swing Note: Most of the stuff stolen from or from the jdk documentation. Most programs are modified or written by me. This section explains the

The Essence of OOP using Java, Nested Top-Level Classes. Preface

Essential Series. Springer-Verlag London Ltd.

AWT WINDOW CLASS. The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager.

HTML p. 1 Introduction to HTML p. 1 Getting Started p. 1 The Structure of an HTML Page p. 1 HTML Basics p. 3 The Weather Forecast Page p.

Supporting Materials

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

An Introduction To Graphical User Interfaces

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

Appendix A. lava Packages

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Contents Introduction 1

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

A Java-based Course in Human-Computer Interaction. Eileen Kraemer. The University of Georgia. Athens, GA interface.

10/11/18. Introduction Panel Class Window Class Dialog class FileDialog class Menu, MenuItem class

OOP Interview Questions

Using the API: Introductory Graphics Java Programming 1 Lesson 8

CompSci 230 S Programming Techniques. Basic GUI Components

MyProgram m i ng Lab. get with the programming. Through the power of practice and immediate personalized

Chapter 13 GUI Basics. Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved.

CS 11 java track: lecture 3

Programming Languages and Techniques (CIS120)

Graphical User Interfaces. Comp 152

CS 3331 Advanced Object-Oriented Programming Final Exam

VALLIAMMAI ENGINEERING COLLEGE

2110: GUIS: Graphical User Interfaces

Window Interfaces Using Swing Objects

Windows and Events. created originally by Brian Bailey

PESIT Bangalore South Campus

Graphics and Painting

SD Module-1 Advanced JAVA

Murach s Beginning Java with Eclipse

SD Module-1 Advanced JAVA. Assignment No. 4

Core Java SYLLABUS COVERAGE SYLLABUS IN DETAILS

Widgets. Widgets Widget Toolkits. User Interface Widget

BCSCCS407R01 JAVA PROGRAMMING LABORATORY

Transcription:

Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, An Overview Java Programming, Lecture Notes # 110, Revised 02/21/98. Preface Introduction Package java.awt Classes Arranging Components in Containers The Container Classes The Non-Text Input Components Text Input and Output Components Using a Scrollbar Component for Data Input Dialogs The Canvas Component Menus Graphics - Working with Shapes Graphics - Working With Fonts Graphics - Working With Images Working with the PrintJob Class Working with the Toolkit Class Review Preface Students in Prof. Baldwin's Intermediate Java Programming classes at ACC are responsible for knowing and understanding all of the material in this lesson. JDK 1.1 was formally released on February 18, 1997. This lesson was originally written on March 5, 1997 using the software and documentation in the JDK 1.1 download package. Additional updates have been made since then. Introduction This lesson is primarily a preview of what you can expect to find in several lessons immediately following this one. This and the next several lessons concentrate on the package java.awt where most of the functionality exists for providing the user interface to your application or applet. Note that it was the AWT portion of Java that experienced the most significant changes in the release of the Java Development Kit, version 1.1. Much of what you may have learned earlier about version 1.0 was

replaced using new concepts. These lessons will concentrate on the use of JDK 1.1 rather than JDK 1.0. The user interface of a modern computer program involves techniques to activate many of the human senses. We use icons, text boxes, images, sound, boardroom graphics, etc. This and the next several lessons will concentrate on those aspects of the interface that we commonly refer to as the Graphical User Interface (GUI). We will leave other aspects of the interface, such as sound, to be covered in subsequent lessons. Many of the sample programs in the earlier lessons on event handling made use of simple GUI forms without providing much of an explanation as to what was going on. The next few lessons will attempt to rectify that situation by explaining many aspects of creating a Graphical User Interface. Package java.awt Classes As mentioned above, much of the material in this and the next several lessons will be based on the classes of the package java.awt. As of 3/5/97, there were more than fifty classes defined in package java.awt. Of that total, we will be mainly concerned with the ones discussed in the following sections. The classes are grouped in the general order that we will be studying them and each grouping will usually be presented as a separate lesson. However, some groups are so large that it may be necessary to break the group up into more than one lesson. We will also be making heavy use of the classes in the java.awt.event package, but you are already familiar with most of those classes from your study of the previous lessons on event handling in JDK 1.1. Arranging Components in Containers We can place our components in their containers using absolute position coordinates, or we can use any of several different layout managers to do the job. Using layout managers is considered by many to be the safer approach because this approach tends to automatically compensate for differences in screen resolution between platforms. The different layout managers are defined in classes having the following names: BorderLayout CardLayout FlowLayout GridBagLayout GridBagConstraints GridLayout

In addition to the layout manager classes, there is a class named GridBagConstraints that is used to work with the GridBagLayout class as well as a class named Insets that is used to work with other classes. The Container Classes The following hierarchy diagram shows where the container classes Panel, Window, and Frame fit into the overall inheritance hierarchy. We will discuss these three classes as a group, and also discuss their relationship with their superclasses: Container, Component, and Object. java.lang.object +----java.awt.component +----java.awt.container +----java.awt.panel +----java.awt.window +----java.awt.frame Generally, these classes are used to contain components or instances of other classes. The Non-Text Input Components The components in the next group are generally used to allow the user to input (non-text) information to the program, although in some circumstances they could also be used to output information to the user as well. Non-text in this context means that the user can input information without the requirement to use the keys on the keyboard. All of these classes extend the class Component. Button Checkbox Choice List The class named CheckboxGroup does not extend Component, but extends Object instead. As the name suggests, objects of this class can be used to group Checkbox components so that they behave in a mutually exclusive fashion. The lesson on non-text input will discuss the classes listed above. Text Input and Output Components

The lesson on text input and output will deal with the classes TextField and TextArea along with the class Label. The TextField class can be used to produce a component that will accept one line of user text as input. It can also be used to display one line of text in a "non-editable" fashion.. The TextArea class can be used to produce a component that will accept multiple lines of user text as input. It can also be used to display multiple lines of text in a "non-editable" fashion. TextField and TextArea extend TextComponent which extends Component. The Label class can be used to display one line of text. This component is inherently noneditable and that attribute cannot be modified by the program. Using a Scrollbar Component for Data Input A previous lesson in the series on event handling discussed the use of the Scrollbar component in considerable depth. We will let that discussion suffice for out investigation of the Scrollbar component. Dialogs In the lesson on Dialogs, we will investigate the use of the Dialog class. This is a class that produces a dialog, or a window that takes input from the user. This lesson will also investigate the FileDialog class. This class can be used to produce an object that displays a file selection dialog. The Canvas Component A Canvas component is a generic component which needs to be subclassed in order to add functionality. We will investigate various uses of this class in the lesson on the Canvas component. Menus The inheritance hierarchy for menus is as shown below. java.lang.object +----MenuShortcut +----java.awt.menucomponent +----java.awt.menubar

+----java.awt.menuitem +----java.awt.menu +----java.awt.checkboxmenuitem +----java.awt.popupmenu As you might suspect from looking at this diagram, there are a number of interesting issues associated with menus, and we will investigate those issues in the lesson on menus. Graphics - Working with Shapes The Graphics class, which extends the Object class, is the abstract base class for all graphics contexts allowing an application to draw onto components or onto off-screen images. A Graphics object encapsulates the state information needed for the various rendering operations that Java supports. This state information includes: The Component to draw on A translation origin for rendering and clipping coordinates The current clip The current color The current font The current logical pixel operation function (XOR or Paint) The current XOR alternation color (see setxormode) Graphics is a large topic which will encompass several different lessons. The first lesson in the Graphics series will investigate the use of the following classes for the realization of objects of the type indicated by the name of the class. Rectangle Point Polygon Dimension Graphics - Working With Fonts The lesson on graphics and fonts will concentrate on the classes Font and FontMetrics. As you can probably surmise from the names, these classes let you control the font of output text, and also let you determine information about the size of text produced with a particular font. Graphics - Working With Images This lesson on images will concentrate on the classes in the following list:

Image MediaTracker Color SystemColor ScrollPane Working with the PrintJob Class As the name implies, this lesson will be concerned with the new printing capability of JDK 1.1. Working with the Toolkit Class The ToolKit class "is used to bind the abstract AWT classes to a particular native toolkit implementation." There are some interesting methods in this class and we will take a look at them. Review Since this lesson is primarily a preview of subsequent lessons, there is no reason to provide review material for this lesson. -end-