Our objective is to introduce the Java Abstract Window Toolkit to those who are familiar with the Java programming language itself and who either wish to develop Web-based Java applets or teach such material in programming classes. Our first goal is to provide a simple framework for applet development that encompasses placement of components, display of graphical elements and event handling. Our second goal is to introduce the Model-View-Control paradigm and apply it to the applet context, thereby bringing an important tool from object-oriented methodology to this area.
Participants should be familiar with the Java programming language though presumably not the AWT. In addition, some familiarity with object-oriented language concepts including classes, methods, messages, inheritance, interfaces and polymorphism (method overriding) is required.
The complete tutorial requires 3 1/2 hours. We delivered such a presentation at WebNet98 quite successfully (4 hours with a 1/2 hour break). At both CCSC-SE98 and CCSC-RM98 we had only about 1 1/2 hours. In those settings, we were able to achieve our first goal, but were not able to cover anything of the MVC paradigm. For CCSC-NE99, we could either do just the first part Friday or Saturday or or just the second part (reviewing the AWT and focusing on MVC) on Friday or Saturday, or do both parts, one on Friday, the other on Saturday.
Much of Java's appeal derives from the ability to create applets with graphical user interfaces (GUIs) which can be delivered across the web. This workshop introduces the participant to Java's support for these GUIs.
The technical focus is on writing applets using the Abstract Windows Toolkit (AWT). The key AWT topics covered are: the nature of and distinction between controls and graphical elements, the JDK 1.1 event model, layout management, manipulation of text and graphic shapes, control components including buttons, textfields, and checkboxes. Java provides clean interfaces to each of the above elements, allowing even the relative novice to create appealing interfaces.
This workshop also introduces some issues in applet design. In particular, we examine approaches such as MVC (model/view/controller) that impose a separation between the user interface and the underlying application. This separation allows changes to the interface to be made without disturbing the application. For example one might introduce more sophisticated components or add support for alternative input devices.
In addition to the above material, the tutorial will demonstrate a pedagogic tools that are suitable also for incorporating this material into introductory programming classes. Time permitting, these tools and their use will also be a topic of the tutorial.
We have given versions of this tutorial five times before: to our own department, to the faculty of Kingsborough Community College, at CCSC-RM98 (Riverton), CCSC-SE98 (Jefferson City), and WebNet98 (Orlando). Professor Sam Rebelsky ofGrinnell College, the tutorials chair of WebNet98, asked us to present again at EdMedia99, but we will unfortunately be unable to do so because of scheduling.
We are both on the faculty of the Department of Computer and Information Science at Brooklyn College of City University of New York. Each of us possesses nearly twenty years of teaching experience in both university and industrial settings including Brooklyn College, NSA, Bell Labs, Bellcore, NYU, and William Patterson College. We have taught graduate and undergraduate courses in Java and object-oriented programming and are the authors of the recently published Introduction to Programming Using Java-- An Object-Oriented Approach (Addison-Wesley, 1998).
Since joining Brooklyn College in 1981, Professor Arnow's research has encompassed data structures, distributed programming, scripting languages, and parallelization of decision support software. He has published papers on CS education in SIGCSE and related settings, organized or participated in CS education panels in SIGCSE and regional conferences, led two NSF-funded projects in areas of CS education, and organized or co-organized several nationally attended workshops on logic and formal methods in CS education.
Since joining Brooklyn College in 1980, Professor Weiss's research has encompassed data structures, programming language design and translation, object-oriented programming, and multimedia conferencing. He has published papers on CS education in SIGCSE and in other ACM and IEEE publications. He has acted as an educational consultant to industry. Professor Weiss has written and worked on commercial compilers for C, Modula 2, and Pascal. He has also developed several high level language and application translators, most recently, a translation system, written in C++, that converts Visual Basic applications to Visual C++.
PART I: APPLETS AND AWT ESSENTIALS INTRODUCTION GUI In Action What GUI Support Entails GUI Tasks and Issues Applets Life Cycle of An Applet Applet Class (Default) Behavior BASIC ELEMENTS OF AN APPLET Extending The Applet Class (1) Overriding init: Control Creation Event Handling Is Anyone Listening? Listener Registration Extending The Applet Class (2) Maintaining the Display Components vs "Doodles" Graphic Behavior: The Graphics Class Overriding paint: Drawing the doodles Back to events: actionPerformed method Overriding init: Initializing currentColor Running an Applet LAYOUT AND PAINTING General Strategy For Using Canvas MyCanvas: Overview MyCanvas: methods MyCanvas: Instance Variables Applet: BetterBasicElements LAYOUT AND COMPONENT PLACEMENT Components and Containers The add Method LayoutManager Objects Two Layout Managers: Using Layout Managers: setLayout method Panel Class Using Panels: BestBasicElements MORE ABOUT EVENTS Event Classes Java Event Naming Conventions Listener Interfaces BestBasicElements With TextEvents Listener Interfaces With Multiple Methods Pain Reliever: Adapter Classes |
PART II: THE MVC PARADIGM AN INTERFACE DESIGN PROBLEM The CounterApplet Class The init Method The actionPerformed Method An Unexpected Benefit (Bug?) Concerns Good Interface Design Revising the Counter Applet THE MODEL-VIEW-CONTROLLER PARADIGM Model View Controller Document-View Model as Observed Symmetric with Event Handling View as Observer APPLYING MVC TO APPLET DESIGN CounterObserver Interface Counter Class Counters Manipulator Methods Counters Observer-Related Methods CounterApplet Class The counterHasChanged Method MVC, FLEXIBILITY, AND RE-USABILITY Class Overview Counter Class The registerAsObserver Method The notifyObservers Method CounterLogger Class CounterPanel Class CounterAlarmPanel Class The counterHasChanged Method WHAT NEXT? Books Development Tools |