The class LicensePane
LicensePane extens class JPanel by adding a JTextArea and a JScrollPane to it. The JTextArea is used to display the full text of the GNU General Public License. By wrapping this functionality into a separate class it is easier for other classes such as AboutBox to show that info text.
Constructing a LicensePane
The constructor takes a Dimension object to determine the preferred size of the panel to be constructed. In the constructor a new non-editable JTextArea is created with the license text to be displayed as a parameter. The license text is delivered by method getLicenseText (see below). A new JScrollPane is created and the JTextArea is associated with it. The vertical and horizontal scroll bar are set to be displayed as needed.
Finally the JScrollPane containing the JTextArea is added to the LicensePane and the license text is scrolled to the top with method setCaretPosition.
Method getLicenseText
The license text is taken from file ' gpl.txt' delivered in the class path of the distribution of SimplyHTML. Method getResourceAsStream is used to locate the file and to open an InputStream object to it. An InputStreamReader is created on that InputStream and the InputStreamReader is used to create a BufferedReader.
As long as lines are found in ' gpl.txt' they are read and appended to a StringBuffer. Finally the readers are closed properly and the contents of the StringBuffer are returned as a String .