FileDocCategorySizeDatePackage
CanisMinor.javaAPI DocExample1966Sat Apr 23 22:35:40 BST 2005None

CanisMinor

public class CanisMinor extends JFrame

Fields Summary
protected JEditorPane
mEditorPane
protected JTextField
mURLField
Constructors Summary
public CanisMinor(String urlString)

    super("CanisMinor v1.0");
    createGUI(urlString);
  
Methods Summary
protected voidcreateGUI(java.lang.String urlString)

    Container content = getContentPane();
    content.setLayout(new BorderLayout());

    JToolBar urlToolBar = new JToolBar(  );
    mURLField = new JTextField(urlString, 40);
    urlToolBar.add(new JLabel("Location:"));
    urlToolBar.add(mURLField);
    content.add(urlToolBar, BorderLayout.NORTH);

    mEditorPane = new JEditorPane(  );
    mEditorPane.setEditable(false);
    content.add(new JScrollPane(mEditorPane), BorderLayout.CENTER);

    openURL(urlString);  

    mURLField.addActionListener(new ActionListener(  ) {
      public void actionPerformed(ActionEvent ae) {
        openURL(ae.getActionCommand(  ));
      }
    });

    mEditorPane.addHyperlinkListener(new LinkActivator(  ));

    setSize(500, 600);
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
  
public static voidmain(java.lang.String[] args)

    String urlString = "http://www.oreilly.com/catalog/java2d/";
    if (args.length > 0)
       urlString = args[0];
    new CanisMinor( urlString ).setVisible( true );
  
protected voidopenURL(java.lang.String urlString)

    try {
      URL url = new URL(urlString);
      mEditorPane.setPage(url);
      mURLField.setText(url.toExternalForm(  ));
    }
    catch (Exception e) {
      System.out.println("Couldn't open " + urlString + ":" + e);
    }