setSize(500, 600);
center( );
Container content = getContentPane( );
content.setLayout(new BorderLayout( ));
// add the URL control
JToolBar urlToolBar = new JToolBar( );
mURLField = new JTextField(urlString, 40);
urlToolBar.add(new JLabel("Location:"));
urlToolBar.add(mURLField);
content.add(urlToolBar, BorderLayout.NORTH);
// add the editor pane
mEditorPane = new JEditorPane( );
mEditorPane.setEditable(false);
content.add(new JScrollPane(mEditorPane), BorderLayout.CENTER);
// open the initial URL
openURL(urlString);
// go to a new location when enter is pressed in the URL field
mURLField.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent ae) {
openURL(ae.getActionCommand( ));
}
});
// add the plumbing to make links work
mEditorPane.addHyperlinkListener(new LinkActivator( ));
// exit the application when the window is closed
addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent e) { System.exit(0); }
});