📄 octopushelptoolbar.java
字号:
/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
Copyright (C) 2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.webdocwf.util.loader.wizard;
// Java core packages
import java.awt.*;
import java.awt.event.*;
import java.net.*;
// Java extension packages
import javax.swing.*;
import javax.swing.event.*;
public class OctopusHelpToolBar extends JToolBar
implements HyperlinkListener {
private OctopusHelpPane webBrowserPane;
private JButton backButton;
private JButton forwardButton;
private JTextField urlTextField;
// WebToolBar constructor
public OctopusHelpToolBar( OctopusHelpPane browser )
{
super( "Web Navigation" );
// register for HyperlinkEvents
webBrowserPane = browser;
webBrowserPane.addHyperlinkListener( this );
// create JTextField for entering URLs
urlTextField = new JTextField( 25 );
urlTextField.setVisible(false);
urlTextField.addActionListener(
new ActionListener() {
// navigate webBrowser to user-entered URL
public void actionPerformed( ActionEvent event )
{
// attempt to load URL in webBrowserPane
try {
URL url = new URL( urlTextField.getText() );
webBrowserPane.goToURL( url );
}
// handle invalid URL
catch ( MalformedURLException urlException ) {
urlException.printStackTrace();
}
}
}
);
// create JButton for navigating to previous history URL
backButton = new JButton( new ImageIcon(
getClass().getResource( "images/Back16.gif" ) ) );
backButton.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event )
{
// navigate to previous URL
URL url = webBrowserPane.back();
// display URL in urlTextField
urlTextField.setText( url.toString() );
}
}
);
// create JButton for navigating to next history URL
forwardButton = new JButton( new ImageIcon(
getClass().getResource( "images/Forward16.gif" ) ) );
forwardButton.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event )
{
// navigate to next URL
URL url = webBrowserPane.forward();
// display new URL in urlTextField
urlTextField.setText( url.toString() );
}
}
);
// add JButtons and JTextField to WebToolBar
add( backButton );
add( forwardButton );
add( urlTextField );
} // end WebToolBar constructor
// listen for HyperlinkEvents in WebBrowserPane
public void hyperlinkUpdate( HyperlinkEvent event )
{
// if hyperlink was activated, go to hyperlink's URL
if ( event.getEventType() ==
HyperlinkEvent.EventType.ACTIVATED ) {
// get URL from HyperlinkEvent
URL url = event.getURL();
// navigate to URL and display URL in urlTextField
webBrowserPane.goToURL( url );
urlTextField.setText( url.toString() );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -