Swing Examples

When this course was taught, Swing was not yet available for GUI work. If you are doing GUI work in Java now, you should consider using the Swing components rather than the AWT components. I have updated many of the examples from this page to use Swing, and you can find them here: Swinging Highly Caffeinated Programs in Java

Highly Caffeinated Programs in Java

First meeting Friday, January 9, 10-12 AM, Seeley Mudd 207
Second meeting Monday, January 12, 10-12 AM, Seeley Mudd 207
Third meeting Tuesday, January 13, 10-12 AM, Seeley Mudd 207
Fourth meeting Wednesday, January 14, 10-12 AM, Seeley Mudd 207

Have you ever wondered how to write programs with windows, menus and other complex interactions? Learn how to use the programming language Java to create graphically-oriented user interfaces for your computer programs. We will discuss windows, graphics canvases, dialog boxes, input from the mouse, menus and other useful GUI techniques. (And maybe even threads!) Emphasis will be on doing event- driven programming using the Java 1.1 event model.

Unfortunately, previous programming experience in Java is necessary. (Programming experience in other languages might do, please see Prof. Rager) Having taken Computer Science 11 in the fall semester is enough background.

Class Materials


Instructor

John Rager
Office: 402 Seeley Mudd
Phone: x5810
E-mail: jer@cs.amherst.edu


Various information


Sample Programs


Remember - these programs will only run in Java 1.1 You will need to save copies of the files if you are accessing this using a browser.

Friday's Examples

To run friday's examples from your appletviewer, just specify the correct URL:
http://www.cs.amherst.edu/~jer/interjava/Friday/TrivialApplet.html
http://www.cs.amherst.edu/~jer/interjava/Friday/Dual1.html
etc.

  • Download all examples, java and html(Zip File)

  • "Hello World" Applet
  • Applet with Button and Label - no Action
  • Applet with Button and Label - Applet is ActionListener
  • Applet with Button and Label - ActionListener defined as External Class
  • Applet with Button and Label - ActionListener as Anonymous Inner Class
  • Applet with Button and Label - ActionListener as Named Inner Class

    Monday's Examples


  • Download all examples, java and html(Zip File)

  • Applet with Many Components and Listeners
  • Applet with Canvas
  • Applet with Grid and Flow Layout Managers
  • Applet with Border Layout Manager
  • Applet with Card Layout Manager and PopUp Menu
  • Application with Card Layout Manager, Menu, Event Queue
    This is NOT an applet

    Tuesday's Examples


  • Download all examples, java and html(Zip File)

  • Applet with PopUp Menu

  • Applet: MouseListener Example (Scribbler)

  • Application: URL

  • Applet: Image display, scaling, flipping and cropping

  • Applet: Image display with Image Observer

  • Application: Cross Layout Manager


    Wednesday's Examples


  • Download all examples, java and html(Zip File)

  • Applet with Moving Banner

  • Application with Synchroniztion

  • Client/Server Pair


    General Examples