import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import javax.swing.*;
public class AboutFrame
extends JFrame
implements ActionListener
{
private static int buttonHeight = 25;
private static int buttonWidth = 100;
private static int mainPaneHeight = 200;
private static int mainPaneWidth = 400;
private JButton okButton;
private JScrollPane scrollPane;
private JTextArea textArea;
private JEditorPane textPane;
private static AboutFrame singleton;
String[] helpStr = new String[]
{
" NJCLApplet version Brainshare US 1999",
"Copyright (c) 1999 Novell, Inc. All Rights Reserved.",
"",
"-----------------------------------------------------",
"",
" !!!MISSING ABOUT.HTML!!!"
};
static public AboutFrame getAboutFrame (
URL codeBase)
{
if (null == singleton)
singleton = new AboutFrame (codeBase);
return (singleton);
}
private AboutFrame (
URL codeBase)
{
super ("About NJCL Applet");
getContentPane ().setLayout (new BorderLayout ());
setSize (mainPaneWidth, mainPaneHeight);
scrollPane = new JScrollPane ();
try
{
textPane = new JEditorPane ();
textPane.setEditable (false);
URL url = new URL (codeBase, "about.html");
textPane.setPage (url);
scrollPane.getViewport ().add (textPane);
}
catch (Exception e)
{
(new MessageBox (
"Error",
"Unable to find about.html (using default):\n" +
Util.getExceptionTrace (e))).show ();
textArea = new JTextArea ();
textArea.setEditable (false);
textArea.setFont (new Font ("Courier", Font.PLAIN, 12));
String newLine = System.getProperty ("line.separator");
for (int i = 0; i < helpStr.length; i++)
textArea.append (helpStr[i] + newLine);
scrollPane.getViewport ().add (textArea);
}
getContentPane ().add (scrollPane, "Center");
JPanel buttonPanel = new JPanel (new FlowLayout (FlowLayout.CENTER));
okButton = new JButton ("OK");
okButton.setToolTipText ("Close this window");
okButton.setSize (buttonWidth, buttonHeight);
okButton.addActionListener (this);
buttonPanel.add (okButton);
getContentPane ().add (buttonPanel, "South");
setDefaultCloseOperation (HIDE_ON_CLOSE);
}
public void actionPerformed (
ActionEvent event)
{
Object object = event.getSource ();
if (object == okButton)
setVisible (false);
}
}