Software Engineering is often seen as a project phase entirely independent from the implementation process. However, a software designer without a good idea of a Web server, or of the structure of a GUI, or of remote calls would be like an architect ignorant of the keystone or reinforced concrete. Developing a complex application requires the understanding of numerous and diverse concepts, scattered across the literature in books representing maybe several thousands of pages. Although no application requires all the features developed by the software community, a software engineer must have some detailed knowledge of those best suited to his or her project; this provides a much needed overview of the concepts that have a potential use in the application…
Graphical User Interfaces Frames and Dialog Boxes
Swing is the Java library available for the construction of GUI (graphical user interface) windows. The documentation proposed by Sun is very well written and it will thus not be completely repeated here. We will rather provide an overview that should allow the reader to quickly understand the basic architectural principles, to select the classes suitable for his project and to find quickly the required information in Sun’s documents.
All windows that appear on a screen are included in a frame, a dialog box or in the frame of an applet. Each frame includes a panel instantiated by default. The panels contain the GUI elements and possibly other panels, which in turn can contain other GUI elements and other panels. Each panel can be provided with a layout manager that indicates how to place the GUI elements and the inner panels in that panel. The default layout of a panel is the FlowLayout.
The GUI elements use a special feature, the listener, to connect the GUI elements to the body of the application. We have also developed an alternative that allows a program to read GUI elements even if the program does not know which element will be triggered next.
Creation of Elements With the Help of Eclipse
The development environment Eclipse has a GUI editor, Visual Editor, available as a separate plugin (see the WebLang site).
In order to insert GUI components or panels, you must click on the corresponding element and then click in either the graphical or the textual representation. The properties can be entered in either the Properties view or, for some of them, by right-clicking either the graphical or the textual representation. In particular, the listeners can be introduced by selecting Events in the menu that appears with the latter right-click.
In the following, we show how to create the various GUI components in a simple way. As Eclipse is an automatic tool, it introduces the elements in some more sophisticated ways, but the explanations remain valid.
Creation of a Frame
Frames are created in one of the two manners presented in the following listings. The first manner is trivial. In the second manner, the frame is inherited in the main object and instantiated when the super() statement is executed. In this case, the inherited frame can be accessed by this or by local calls, an approach that is taken by many developers, although it links the frame to the application for no good reason.
This is the first possibility for generating a frame: it can be generated anywhere in an application…