📄 oaahelpdialog.java
字号:
/*
* @(#)OaaHelpDialog.java 08/1999
*
* The contents of this file are subject to the OAA Community Research
* License Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License
* at http://www.ai.sri.com/~oaa/. Software distributed under the License
* is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific language governing
* rights and limitations under the License. Portions of the software are
* Copyright (c) SRI International, 1999. All rights reserved.
* "OAA" is a registered trademark, and "Open Agent Architecture" is a
* trademark, of SRI International, a California nonprofit public benefit
* corporation.
*/
/*
* file: OaaHelpDialog.java
* purpose: HTML Viewer for Agent's related help files
*/
package com.sri.oaa2.guiutils;
import java.lang.String;
import java.net.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* This class provides a dialog box containing a light HTML browser,
* to display help files for a given agent. <br>
* The brower used is the "Ice browser" from ice.
* @see com.sri.oaa2.guiutils.OaaConnectDialog
* @see com.sri.oaa2.guiutils.OaaAboutDialog
*/
public class OaaHelpDialog extends JFrame implements
ActionListener,
KeyListener {
JToolBar tb = new JToolBar();
JTextField txtStatus = new JTextField("");
OaaBrowser pnlBrowser = new OaaBrowser();
//JEditorPane pnlBrowser = new JEditorPane();
/****************************************************************************
* Constructor.
* @param url The local file or URL pointing to the help file
****************************************************************************/
public OaaHelpDialog(URL url) {
try {
jbInit(url);
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit(URL url) throws Exception {
this.setSize(new Dimension(460, 350));
// Load the URL file
try {
if (url != null) {
System.out.println("Open " + url);
//pnlBrowser.setdocURL(url.toString());
//pnlBrowser.setPage(url);
pnlBrowser.setURL(url);
}
}
catch (Exception e) {
System.out.println("Can not open " + url);
}
addButton("Back");
addButton("Forward");
tb.addSeparator();
addButton("Reload");
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(pnlBrowser, BorderLayout.CENTER);
mainPanel.add(tb, BorderLayout.NORTH);
getContentPane().add(mainPanel);
setTitle("Help...");
setVisible(true);
}
/**
*
*/
private void addButton(String btnName)
{
JButton b;
b = new JButton(new ImageIcon(getClass().getResource("images/" + btnName + ".gif")));
b.setActionCommand(btnName);
b.addActionListener(this);
b.setMargin(new Insets(1,1,1,1));
b.setFocusPainted(false);
b.setToolTipText(btnName);
tb.add(b);
}
private boolean setHTMLPage(String inUrl) {
//pnlBrowser.setdocURL(inUrl);
return true;
}
//-------------KeyListener interface
public void keyTyped(KeyEvent evt) {}
public void keyPressed(KeyEvent evt) {}
public void keyReleased(KeyEvent evt)
{
if (evt.getKeyChar() == KeyEvent.VK_ENTER)
// Go to net adr typed in the textfield at the south of the frame
setHTMLPage(txtStatus.getText());
}
//-------------ActionListener interface
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("Back"))
pnlBrowser.back();
else if (e.getActionCommand().equals("Forward"))
pnlBrowser.forward();
/*
else if (e.getActionCommand().equals("Reload"))
pnlBrowser.reload();
*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -