Java Reference
In-Depth Information
The minimal user interface that satisfies these requirements is a window
containing three components:
an HTML panel;
a text panel with editing capabilities; and
a button for triggering the documentation process.
An example of such an interface is shown in Figure 8.13.
Using the Java UI classes, in particular the Swing set of components, makes
the realization of the above-described interface fairly simple.
The graphical component classes that we will use are:
JeditorPane , which is able to display HTML content;
JtextArea , which is a text area with editing capabilities;
Jbutton , which is a button.
The whole window can be realized by means of a class that extends the
JFrame class.
In order to make the JEditorPane and the JTextArea scrollable they have to
be embellished by the JScrollPane class. The description of further details
concerning the implementation of the user interface is beyond the scope of
this chapter.
The graphical driver consists of a single class, TestFrame , which extends that
Swing class JFrame . It contains three visual components: a text area, an
HTML panel and a button. The text area contains the source code of a Java
class. Pressing the button fills the HTML panel with the documentation of
the class. This class also implements the interfaces ActionListener and
HyperlinkListener which define the methods that handle a click on the button
and a click on a link in the HTML pane respectively.
Figure 8.13 The user interface
Search WWH ::

Custom Search