Introduction
Home ] Up ] [ Introduction ] The Swing Package ] Frames ] Panes, Text & Fonts ] Colors ] Shapes ] Paint Modes ] Images ]

 

 

What is Graphical Programming?

It's using a graphical user interface (GUI) rather than a command line style.  GUI programs are what most people want to see these days.

How you write GUI programs is very different from how you write conventional programs.   The approach is to use events to drive the program -- event-driven programming. 

AWT

In Java 1.0, the language provided a set of classes that were intended to allow you to build GUI programs in a platform-independent way.  This was the AWT, variously called:
  • The Abstract Window Toolkit
  • "The Alternative Window Toolkit"
  • "The Awful Window Toolkit"

The AWT is a platform-independent windowing/graphics toolkit, and exists in library of classes in package  java.awt.

AWT Shortcomings

Unfortunately, there were a number of shortcomings to the AWT.   Since the AWT relied on the underlying windowing system on each platform, it:

  • Tended to be a least common denominator approach;  if something couldn't be done on one platform, then it couldn't be done on any platform.
  • AWT did not have the capabilities that were considered normal on Windows and Mac platforms, because of its least common denominator approach, so Java GUIs didn't look or behave as well as native GUIs on those platforms.
  • For each AWT component, Java relied on a native windowing system peer component, that handled most of the work.  This became a restriction, and also had major performance and resource consumption problems for any non-trivial GUI program.
  • Because each platform's implementation depended on the underlying windowing system for that platform, each platform had its own set of bugs, which drove Java programmers crazy.
    • "Write once, run anywhere." became "Write once, debug everywhere."

JFC/Swing

So, JDK 1.2 introduced a new, far more functional and flexible set of classes called JFC (Java Foundation Classes).  A subset of these classes is known as Swing, which solves the above problems pretty well.  It is now possible (and relatively easy) to create a good-looking and usable GUI for your programs that is portable across Java platforms.

We will get into more details on JFC and Swing later on in the course.

It is important to note that JFC/Swing is not a replacement for everything in the AWT.  Rather, many of the AWT classes are used heavily when you use JFC/Swing.  Some classes in JFC/Swing are replacements for some classes in the AWT (JFrame for Frame, JApplet for Applet, etc.), but other classes in the AWT are retained and are still well used.

 

This page was last modified on 02 October, 2007