super("Help Window");
cp = getContentPane();
getAccessibleContext().setAccessibleName("TestEdit Help Window");
getAccessibleContext().setAccessibleDescription("A window for viewing TestEdit HELP, which is somewhat hyperlinked.");
try {
URL url = new URL("file:///"+ System.getProperty("user.dir")+
"/help/index.html");
// Only create the window once.
if (help == null) {
// System.out.println("Creat-ing help window for " + url);
help = new JEditorPane(url);
// System.out.println("Done!");
help.setEditable(false);
help.addHyperlinkListener(this);
JScrollPane scroller = new JScrollPane();
scroller.setBorder(BorderFactory.createTitledBorder("TestEdit Help"));
scroller.getViewport().add(help);
cp.add(BorderLayout.CENTER, scroller);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
MyHelp.this.setVisible(false);
MyHelp.this.dispose();
}
});
setSize(500,400);
} else {
System.out.println("Re-using help window!");
}
} catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e);
} catch (IOException e) {
System.out.println("IOException: " + e);
}