3. Java's Support for GUI Programming

With graphical user interfaces now standard among everyday software applications, it seems odd to continue to teach students to write only programs that perform character I/O. Yet that is the norm in many introductory computer science courses. One reason for this situation is that graphical user interfaces are traditionally tied to a particular platform or even a particular software vendor. Another is that writing programs that use these interfaces is an arduous task.

Various solutions have been proposed to the problem of introducing GUI programming into the computer science curriculum. One solution is to let students write GUI programs in a proprietary language like Microsoft's Visual Basic or Borland's Delphi. Another is to develop simplified libraries that shield students from the complexity of a commercial GUI application interface [10, 16]. The alternative--asking students to write in C++ and master the Microsoft Foundation Classes (MFC) or Borland's Object Windows Library (OWL)--is difficult, and students won't progress with any speed [15].

Java changes all that. Java comes with a platform-independent windowing API, known as the Abstract Windowing Toolkit (AWT). Java's AWT is remarkably easy to use. A simple component, such as a button, can be created and added to the screen in one statement. Handling an event (such as that triggered when the button is pressed) isn't much harder. Using AWT, students can write GUI programs with ease, and their programs will run on a variety of platforms. Once they're familiar with the event-driven nature of GUI programming and the basic components from which GUI programs are built, they'll be better prepared to tackle the complexities of MFC or OWL in a subsequent course.

AWT supports not just GUI components, but graphics and sound as well. The advantages of using graphics in introductory classes are well documented [12]. With Java, it's easy for beginners to incorporate graphics, animation, and sound in their programs.

Next section


Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.

© 1997 ACM