1 21 22 package org.webdocwf.util.loader.wizard; 23 24 import java.awt.*; 26 import java.awt.event.*; 27 import java.net.*; 28 29 import javax.swing.*; 31 import javax.swing.event.*; 32 33 public class OctopusHelpToolBar extends JToolBar 34 implements HyperlinkListener { 35 36 private OctopusHelpPane webBrowserPane; 37 private JButton backButton; 38 private JButton forwardButton; 39 private JTextField urlTextField; 40 41 public OctopusHelpToolBar( OctopusHelpPane browser ) 43 { 44 super( "Web Navigation" ); 45 46 webBrowserPane = browser; 48 webBrowserPane.addHyperlinkListener( this ); 49 50 urlTextField = new JTextField( 25 ); 52 urlTextField.setVisible(false); 53 urlTextField.addActionListener( 54 new ActionListener() { 55 56 public void actionPerformed( ActionEvent event ) 58 { 59 try { 61 URL url = new URL( urlTextField.getText() ); 62 webBrowserPane.goToURL( url ); 63 } 64 65 catch ( MalformedURLException urlException ) { 67 urlException.printStackTrace(); 68 } 69 } 70 } 71 ); 72 73 backButton = new JButton( new ImageIcon( 75 getClass().getResource( "images/Back16.gif" ) ) ); 76 77 backButton.addActionListener( 78 new ActionListener() { 79 80 public void actionPerformed( ActionEvent event ) 81 { 82 URL url = webBrowserPane.back(); 84 85 urlTextField.setText( url.toString() ); 87 } 88 } 89 ); 90 91 forwardButton = new JButton( new ImageIcon( 93 getClass().getResource( "images/Forward16.gif" ) ) ); 94 95 forwardButton.addActionListener( 96 new ActionListener() { 97 98 public void actionPerformed( ActionEvent event ) 99 { 100 URL url = webBrowserPane.forward(); 102 103 urlTextField.setText( url.toString() ); 105 } 106 } 107 ); 108 109 add( backButton ); 111 add( forwardButton ); 112 add( urlTextField ); 113 114 } 116 public void hyperlinkUpdate( HyperlinkEvent event ) 118 { 119 if ( event.getEventType() == 121 HyperlinkEvent.EventType.ACTIVATED ) { 122 123 URL url = event.getURL(); 125 126 webBrowserPane.goToURL( url ); 128 urlTextField.setText( url.toString() ); 129 } 130 } 131 } | Popular Tags |