This tutorial is a Java 1.3 version of material originally developed by Gregory C. Walsh, Department of Mechanical Engineering in 1999-2000.
In Greg's tutorial, all of the graphics were implemented using the Abstract Windowing Toolkit (AWT). Here we clean up some of the source code and update the graphics to Java Swing.
The purpose of this set of lessons is to get you started on your Java project. All code is included. Each lesson is intended to illustrate some of the features supported in the Java language as well as classes available in the free toolkits. People have been asking aout the file jpath.bat that I use to initialize the console Window on my windows 95 box. The file contents (for Java 1.2) are as follows:
set PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\jdk1.2\bin doskey
There are a total of 6 lessons. Writing to and from a console
window is covered in Austin and Chacogne, we will discuss only
creating applets which can be integrated into your web page.
These lessons are primarily inspired by The Java Tutorial,
written by Mary Campione and Kathy Walrath. I recommend the book
if you will be programming in Java. Screen shots of the applets
in each lesson (no Java required) can be found at the
screen shot page.
Lessons
Lesson | Lesson Contents | Applet |
Lesson 1: Hello world | Creating a first applet | Applet |
Lesson 2: Zap-bang-pow | Creating and using buttons | Applet |
Lesson 3: Mug Shot Project | Layout of components, images | Applet |
Lesson 4: Scribling | Mouse listeners and Colors | Applet |
Lesson 5: Total Bomb | Double buffers, Threads, Animation | Applet |
Lesson 6: Course Review | Client server application | Applet |
At the end of each lesson, you can access the byte code I generated to see how the applet is supposed to run. Of course, you are supposed to generate the applet yourself, and run it locally in your own account!
The following examples I have written possess features which may be similar to the projects many students are considering. There is also a large number of really neat examples with source code in the documentation which comes with the Java Development Kit. I have not had a chance to produce lessons for them.
Of course it is hard to compete with the great examples which were produced for the JDK. Check them out! They are under the demo directory. My favorite is GraphLayout.
If you wish to: | Goto | If you wish to: | Goto |
Compile a java applet | Lesson 1 | Integrate applet into web page | Lesson 1 |
Create Buttons | Lesson 2 | Enable and disable Buttons | Lesson 2 |
Intercept Button events | Lesson 2 | Pass parameters to applet | Lesson 2 |
Load and display images | Lesson 3 | Use layout managers | Lesson 3 |
Use a Scrollbar or Choice | Lesson 4 | Intercept mouse events | Lesson 4 |
Use the GridBagLayout | Lesson 4 | Use the BorderLayout | Lesson 3 |
Create a thread | Lesson 5 | Animate | Lesson 5 |
The JDK comes with several standard data structures (Vector, Stack, Hashtable, etc) and some associated algorithms, found in the util section. Understanding data structures and algorithms is very important if you plan to program seriously. We unfortunately do not have time to introduce data structures and algorithms in a serious way. The main inspiration for the following examples is Data Structures and Algorithms in Java by Michael Goodrich and Roberto Tamassia.
Originally developed in 1999 by Greg Walsh
Modified in April 2001 by Mark Austin
Copyright © 1999-2001, Departments of Civil and Mechanical Engineering,
University of Maryland