Full HTML for

Basic foilset Overview of JDK Version 1.1 Extensions

Given by Nancy J. McCracken at CPS616 -- Information Track of CPS on Spring Semester 97. Foils prepared 19 July 97
Outside Index Summary of Material


The first part of this talk gives an overview of the extensions and changes in Java now available in JDK 1.1:
  • Java language: inner classes, internationalization, and object serialization
  • Major extensions to the Abstract Windowing Toolkit (AWT) for writing UI's: lightweight components to allow more control and more sophistication in UI, and more general event handling model.
  • Security: signed applets and cryptographic API's
  • Distributed Computing: JDBC, RMI, and JavaBeans
  • We will briefly mention plans for enterprise and commerce extensions, and additional extensions such as the "Swing set".
The second part of this talk goes into more detail on language changes and on the new AWT event model. (Other talks give details on JDBC, security, and JavaBeans.)

Table of Contents for full HTML of Overview of JDK Version 1.1 Extensions

Denote Foils where HTML is sufficient
denotes presence of Additional linked information which is greyed out if missing

1 Java Development Kit (JDK) 1.1: Overview and new AWT Event Model
2 See NPACs other resources page for Sun Java TUtorial for 1.1 information JDK 1.1 Overview and AWT Events Abstract
3 Suns page for Java Development Kit Downloads Availability of JDK 1.1
4 AWT New Event Model
5 AWT Lightweight Components
6 Java Language Inner Classes
7 Java Language Internationalization
8 Object Serialization
9 Java Security
10 Java Signed Applets
11 JDBC - Java Database Connection
12 JavaBeans
13 Building applications from JavaBeans
14 In development over next year
15 AWT: The Swing Set
16 AWT: Data Transfer "Drag and Drop"
17 Other Developments
18 New Language Features and Event Model
19 Inner Classes - Member Classes
20 Inner Classes - Member Classes
21 Inner Classes - Local Classes
22 Event Model in Java 1.0
23 Event Model in Java 1.1
24 Event Objects
25 Event Sources
26 Event Listeners
27 Examples of Event, Listener Interface and Methods:
28 JDK1.1 Events for Foil 28 How to Write an Event Listener
29 New AWT Component: ScrollPane
30 New AWT component: PopupMenu

Outside Index Summary of Material



HTML version of Basic Foils prepared 19 July 97

Foil 1 Java Development Kit (JDK) 1.1: Overview and new AWT Event Model

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
7/17/97
Nancy McCracken
NPAC

HTML version of Basic Foils prepared 19 July 97

Foil 2 JDK 1.1 Overview and AWT Events Abstract

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index See NPACs other resources page for Sun Java TUtorial for 1.1 information
The first part of this talk gives an overview of the extensions and changes in Java now available in JDK 1.1:
  • Java language: inner classes, internationalization, and object serialization
  • Major extensions to the Abstract Windowing Toolkit (AWT) for writing UI's: lightweight components to allow more control and more sophistication in UI, and more general event handling model.
  • Security: signed applets and cryptographic API's
  • Distributed Computing: JDBC, RMI, and JavaBeans
  • We will briefly mention plans for enterprise and commerce extensions, and additional extensions such as the "Swing set".
The second part of this talk goes into more detail on language changes and on the new AWT event model. (Other talks give details on JDBC, security, and JavaBeans.)

HTML version of Basic Foils prepared 19 July 97

Foil 3 Availability of JDK 1.1

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index Suns page for Java Development Kit Downloads
The JDK 1.1 development system including the compiler is available for all platforms except MacOS by downloading from http://www.javasoft.com. JDK 1.1 includes
  • compiler javac, interpreter java, and appletviewer as before
  • additional tools
    • jar, for creating Java Archive files
    • javakey, for digital signatures
    • serialver, for verifying version of serialized object
    • native2ascii, for converting source files in other formats
    • other tools for RMI
Some features, such as JDBC, which were actually released over last year, are supported in current browsers such as Netscape 3.0. Most AWT stuff is currently only available in HotJava browser (or in JDK 1.1 appletviewer).

HTML version of Basic Foils prepared 19 July 97

Foil 4 AWT New Event Model

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
In old event model, the native windowing system reported events to the eventHandler of class Component, who decided which component should get the event and to call a particular event handler for that event, such as "action" or "mouseDown".
In the new event model, event handling has been more generalized: each class can declare which events it wants to handle by creating an ActionListener for those events.
  • Required more generalized event model for JavaBeans.
  • Essential for user to create own basic (lightweight) components.
  • More detailed system of events: e.g. user can create own button component which enables events MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_ENTERED, and MOUSE_EXITED and may make the button change appearance (or take other action) on each of these events.

HTML version of Basic Foils prepared 19 July 97

Foil 5 AWT Lightweight Components

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
In former releases of JDK, components were implemented by a peer class in the native window system, called "heavyweight components". These have problems:
  • Native components are always rectangular and opaque.
  • Native windows are handled differently on different platforms resulting in complex AWT logic to try (sometimes unsuccessfully!) to preserve consistent performance across platforms.
JDK 1.1 has Lightweight UI Framework: subclasses of Component and Container are now implemented wholly in Java code without native code
  • User can define look of components, including transparent backgrounds, round buttons, etc., giving common "look and feel" across platforms.
  • Current built-in classes for basic components such as buttons are in process of being re-implemented as lightweight (see swing set)

HTML version of Basic Foils prepared 19 July 97

Foil 6 Java Language Inner Classes

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
JDK 1.1 has fixed annoying problem of having to create a totally separate class for such structuring things as creating a class to handle a subcomponent of the applet window. You can now create such classes locally within the applet as an inner class.
  • Only one instance is created of an inner class.
  • The inner class can refer to instance variables of the enclosing class.

HTML version of Basic Foils prepared 19 July 97

Foil 7 Java Language Internationalization

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
There is a new class Locale which can be used in Java code so that one Java program, a "global program", can be written which uses different character sets, time, date and currency formatting depending on where it is run.
  • Implements UniCODE 2.0 for character sets
  • Internationalization makes small changes in various classes such as String, Properties, Exceptions, System and Runtime.
  • At JavaOne conference, Gosling remarks that majority of bytes of new stuff in JDK 1.1 is for new conversion tables for internationalization. Much of this was incorporated from IBM and Taligent.

HTML version of Basic Foils prepared 19 July 97

Foil 8 Object Serialization

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Provides the ability to write the complete state of an object to an output stream and then recreate the object later by reading the serialized representation from an input stream.
Classes ObjectOutputStream and ObjectInputStream have methods to read and write objects (as well as primitive types).
Used for transferring objects in cut-and-paste, RMI, and JavaBeans.
Also useful for saving customized or pre-initialized states of objects such as GUI's.

HTML version of Basic Foils prepared 19 July 97

Foil 9 Java Security

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
The first release of the new Java security package has
  • Digital signatures: algorithms such as DSA for generating public/private key pairs, signing and verifying digital data.
  • Message digests: one-way hash algorithms for producing "digital fingerprints" of data, frequently used in digital signatures.
  • Key management: system of managing individual users and groups with keys and certificates.
  • Access control lists: access permissions.
Some of these interfaces are abstract - implementations are provided in "Java Cryptography Extension" (JCE) released separately to JDK "in accordance with U.S. export control regulations".
  • Each JDK can have one or more "Cryptography Package Provider" installed. Default is Sun, but users can install own cryptography package.

HTML version of Basic Foils prepared 19 July 97

Foil 10 Java Signed Applets

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
The new JAR file format is for Java Archives - a file that can contain Java classes and other data, such as images and sounds. The JAR format accomplishes several goals:
  • Data compression for faster downloading - claims to decrease download time from 2-5 times.
  • Signed applets
  • Also used by JavaBeans
A signed applet from a trusted entity can be downloaded to run under appletviewer with full rights as a local application. They do not run under a regular browser where applets come under the regular "sandbox" restrictions of the Java security model.

HTML version of Basic Foils prepared 19 July 97

Foil 11 JDBC - Java Database Connection

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Provides Java interface to legacy databases
Open interface specification to SQL databases - JDBC classes provide methods for programmers to issue SQL statements and process the results in Java.
Crucial part is database drivers to provide interface between JDBC classes and the proprietary database product.
  • 20 JDBC drivers now exist and 41 companies have endorsed the JDBC API.
  • There is also a JDBC-ODBC Bridge driver which can turn most ODBC drivers into JDBC drivers.

HTML version of Basic Foils prepared 19 July 97

Foil 12 JavaBeans

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Goal is to provide platform-independent component architecture. Developer writes reusable software components and then puts together applications from components using a visual builder's tool.
A Java Bean is a reusable component. It is different from an ordinary class because its method signatures and class definitions allow introspection (by the application builder's tool). Introspection can find
  • properties - these can not only be inspected but set, to allow customization
  • events
  • Visual interface(BeanBox) accesses properties of individual Beans and can link them together to form complex programs
Beans also allow persistence - a bean can be customized and then stored back to disk.
A Bean implements the Java interface "Serializable" which allows the builder tool to work with design time and run time.

HTML version of Basic Foils prepared 19 July 97

Foil 13 Building applications from JavaBeans

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Beans can be simple components like buttons, textfields, scrollbars, etc., or they can be complex entities like calculators or text editors, which were themselves composed out of other components.
Typically, the builder's tool has a visual interface, akin to Visual Basic or Delphi, in which you can select Bean components to place on your window and hook up events to particular actions.
The Bean Development Kit (BDK) comes with a testing tool, the Bean Box.
It also comes with a Bridge for ActiveX and the Migration Assistant for ActiveX.

HTML version of Basic Foils prepared 19 July 97

Foil 14 In development over next year

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Sun is working with a number of other companies on things which, in addition to JavaBeans, will support enterprise computing.
  • One of these is the Java Naming and Directory Interface (JNDI) which will work out naming systems across a corporate-wide set of software.
  • Another is a transaction service API, to go along with the JDBC support for individual database accesses.
Sun is also still working on expanding media API to include more sound classes, mixed stereo, MIDI files
They are working on performance tools
  • to find such things as "20% of your applet execution time was spent repainting that button!"

HTML version of Basic Foils prepared 19 July 97

Foil 15 AWT: The Swing Set

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
This is a whole set of GUI components being implemented using the Lightweight UI Framework.
  • includes rewriting in Java all the original components
  • will add a rich set of higher-level components such as tree viewers, rich text viewers, HTML plug-in, and various standard dialog boxes such as color chooser, file chooser, date chooser
Makes the "look and feel" of components "pluggable" to allow developers to customize look and feel of applications.
Swing Set is part of the newly announce Java Foundation Classes (JFC) which is a large collection of classes designed for building visual applications in Java. Some ideas are based on Netscape's Internet Foundation Classes toolkit. Sunsoft, Netscape, IBM, Symantec and Lighthouse Design are collaborating.

HTML version of Basic Foils prepared 19 July 97

Foil 16 AWT: Data Transfer "Drag and Drop"

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Design work is going on to supply data transfer capability for Java objects, on top of which transfer-protocols can be built. The two API's are
  • Clipboard
  • Drag and Drop: DragSouce and DropTarget
A key issue is data format of objects to be transferred - Java is putting in a set of data "flavors" based on MIME types to represent objects.

HTML version of Basic Foils prepared 19 July 97

Foil 17 Other Developments

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
As Java classes grow, Sun sees need for Personal Java, a stripped down version of Java with a core set of classes. A prototype has been developed that was used in a version of WebTV demoed at JavaOne.
Sun has applied to the ISO to become a "submitter of standards" for Java and JavaVM. This requires Sun to conduct an open process for standard development and to ensure a high level of industry participation.

HTML version of Basic Foils prepared 19 July 97

Foil 18 New Language Features and Event Model

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index

HTML version of Basic Foils prepared 19 July 97

Foil 19 Inner Classes - Member Classes

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
A class can be defined as a member of another class, analogous to instance variables and methods.
The code within the member class can refer to any fields and methods of the enclosing class.
Every instance of a member class is associated with a particular instance of the enclosing class.
Syntax: public class A { //declare instance variables and methods of A here //methods may create new B private class B { //declare instance variables and methods of B here //methods can refer to instance vars and methods of A } }

HTML version of Basic Foils prepared 19 July 97

Foil 20 Inner Classes - Member Classes

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Member classes introduce complications to the name space since there is now both scope (since a member class has a containing class) and inheritance (since a member class can have a superclass). Scope and inheritance form two distinct hierarchies.
If a member class refers to a name which is both in its containing class and its superclass, the name in the superclass is used as it is considered to be in the current scope, so inheritance takes precedence.
The Java compiler may require you to make this clear in the syntax by using this.x for an inherited name and A.this.x for a name in containing class A.

HTML version of Basic Foils prepared 19 July 97

Foil 21 Inner Classes - Local Classes

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
A local class is defined within a block a Java code, typically a method, but also static and instance initializers.
The local class is only visible within the block of code in which its defined.
It can use any final (can't be overriden by subclass) local variables or method parameters within its scope.
Syntax: just declare the class and use it entirely within one block, such as a method. (Note that use of "final" modifier is liberalized.)
Unlike member classes, local classes can refer to local variables of block they're defined in.
Typical use of local classes is to define "event listeners".
There are also anonymous local classes, introduced without a name. Special syntax not covered here.

HTML version of Basic Foils prepared 19 July 97

Foil 22 Event Model in Java 1.0

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
All events are represented by the Event class. The instance variable, id, represents the type of the event, such as a button click. Another instance variable, target, specifies the object which generated the event, such as which button.
Events are dispatched first to the handleEvent() method of the Component in which they occurred. If possible, this method will pass the event on to an appropriate specific event handler such as action(), mouseDown(), etc.
If the event handler returns true, it handled the event and it's over. Otherwise, handleEvent passes the event on to the container in which that component resides, and so on.

HTML version of Basic Foils prepared 19 July 97

Foil 23 Event Model in Java 1.1

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
Based on concept of "event listener":
  • An event listener is any object which wants to receive events.
  • An event source is an object which generates events. An event source will keep a list of event listeners who want to be notified for particular events.
  • The event source notifies event listeners by invoking a particular method in the event listener and passing it an event object, which has all the information about the event.
  • Example: a component with a button is an event source. Formerly, a button click was reported to the action method of the component. The button click event is now called ActionEvent. You must write a class which implements ActionListener (which can be local to the component) and which provides a method called actionPerformed(). This method will receive the event object and take appropriate action.

HTML version of Basic Foils prepared 19 July 97

Foil 24 Event Objects

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
new class java.awt.EventObject is parent of all events, including those for AWT, java.awt.AWTEvent.
Every event has a source object, obtained by getSource() and a type value, obtained by getID().
  • For example, FocusEvent has two types: FocusEvent.FOCUS_GAINED and FocusEvent.FOCUS_LOST.
Event subclasses also have methods for whatever data is needed to handle the event.
  • For example, MouseEvent has getX(), getY(), and getClickCount(), also inherits getModifiers(), and getWhen()

HTML version of Basic Foils prepared 19 July 97

Foil 25 Event Sources

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
In the AWT, the event sources are the Components.
For every event X which a source generates, its API includes methods to register event listeners: addXListener() and removeXListener().
List of some components and events they generate:
  • Button ActionEvent (button clicked)
  • Checkbox ItemEvent (select or deselect item)
  • Choice ItemEvent
  • Component ComponentEvent, FocusEvent, KeyEvent, MouseEvent
  • List ActionEvent (doubleclick item), ItemEvent
  • MenuItem ActionEvent
  • Scrollbar AdjustmentEvent (move scrollbar)
  • TextComponent TextEvent (user changes text)
  • Window WindowEvent (window opened, closed, etc.)

HTML version of Basic Foils prepared 19 July 97

Foil 26 Event Listeners

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
An event listener is a class that you write to handle events.
For each event type, the java.awt.event package defines an event listener interface. For example, an event listener to receive an ActionEvent must implement the ActionListener interface. (Actually, MouseEvents have two interfaces MouseListener and MouseMotionListener.)
Each listener interface defines one or more method names, which must be implemented in the event listener.

HTML version of Basic Foils prepared 19 July 97

Foil 27 Examples of Event, Listener Interface and Methods:

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
ActionEvent ActionListener actionPerformed()
AdjustmentEvent AdjustmentListener adjustmentValueChanged()
ComponentEvent ComponentListener componentHidden() componentResized()
FocusEvent FocusListener focusGained() focusLost()
ItemEvent ItemListener itemStateChanged()
KeyEvent KeyListener keyPressed() keyReleased() keyTyped()
MouseEvent MouseListener mouseClicked() mouseEntered(), mousePressed() mouseReleased() MouseMotionListener mouseDragged() mouseMoved()

HTML version of Basic Foils prepared 19 July 97

Foil 28 How to Write an Event Listener

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index JDK1.1 Events for Foil 28
Two ways: write the event listener class, implementing all method names or
Subclass an adapter class. For each interface that has more than one method, java.awt.event provides an adapter class. This is a class that implements the interface by implementing all method names with an empty body (ignoring event). If you wish to only handle some event types and not others, you can subclass the adapter class and override only those methods used in your application.
Then your code (applet or application) will create an instance of your event listener class and register it with the event source by calling the addXListener method of the component generating the event.

HTML version of Basic Foils prepared 19 July 97

Foil 29 New AWT Component: ScrollPane

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
ScrollPane is a container that can hold a component area bigger than it shows on the screen. It provides vertical and horizontal scrollers.
Quite easy to create and add as you would any other container.
Main difference is that it doesn't have a "natural" size so you should call setSize(n, m) to set its size to n by m pixels.

HTML version of Basic Foils prepared 19 July 97

Foil 30 New AWT component: PopupMenu

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. *
Full HTML Index
PopupMenus are defined with similar methods as regular Menus - there are methods to add menuItems.
When you add the PopupMenu itself to a component, it doesn't appear in the component window.
In the MouseListener, in the processMouseEvent() method, you can respond to the user's mouse click in the component by calling the show() method of the PopupMenu to make it appear.
The items of the PopupMenu can cause events, and you would create event listeners for those events in the usual way.
Another new AWT feature is that regular Menus can have keyboard MenuShortcuts.

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Nov 29 1998