请教
import java.awt.BorderLayout;import java.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import com.jgoodies.forms.factories.DefaultComponentFactory;
import com.swtdesigner.SwingResourceManager;
public class Liulanqi extends JFrame {
private JTextField textFieldURL;
private JMenuBar menuBar;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
Liulanqi frame = new Liulanqi();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public Liulanqi() {
super();
setTitle("Show");
setName("go");
setBounds(100, 100, 611, 408);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JToolBar toolBar = new JToolBar();
getContentPane().add(toolBar, BorderLayout.NORTH);
final JButton button_1 = new JButton();
button_1.setName("backButton");
button_1.setIcon(SwingResourceManager.getIcon(Liulanqi.class, "back16.gif"));
toolBar.add(button_1);
final JButton button = new JButton();
button.setName("forwardButton");
button.setIcon(SwingResourceManager.getIcon(Liulanqi.class, "forward16.gif"));
toolBar.add(button);
final JButton button_2 = new JButton();
button_2.setName("shiftButton");
button_2.setIcon(SwingResourceManager.getIcon(Liulanqi.class, "refresh16.gif"));
toolBar.add(button_2);
final JLabel locationLabel = new JLabel();
locationLabel.setText("Location:");
toolBar.add(locationLabel);
textFieldURL = new JTextField();
toolBar.add(textFieldURL);
final JButton goButton = new JButton();
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
gobutton_actionPerformed(arg0);
}
});
goButton.setText("Go");
toolBar.add(goButton);
final JButton button_4 = new JButton();
button_4.setIcon(SwingResourceManager.getIcon(Liulanqi.class, "s.gif"));
toolBar.add(button_4);
menuBar = new JMenuBar();
setJMenuBar(menuBar);
final JMenu menu = new JMenu();
menu.setText("文件");
menuBar.add(menu);
final JMenuItem menuItem = new JMenuItem();
menuItem.setText("退出");
menu.add(menuItem);
final JMenu menu_1 = new JMenu();
menu_1.setText("标签");
menuBar.add(menu_1);
final JMenuItem menuItem_1 = new JMenuItem();
menuItem_1.setText("添加到收藏夹");
menu_1.add(menuItem_1);
final JMenuItem menuItem_2 = new JMenuItem();
menuItem_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
menuItem_2.setText("删除收藏夹");
menu_1.add(menuItem_2);
final JMenu menu_2 = new JMenu();
menu_2.setText("帮助");
menuBar.add(menu_2);
JEditorPane jEditorPane = new JEditorPane();
jEditorPane.setEditable(false); // 设置不可编辑
getContentPane().add(jEditorPane, BorderLayout.CENTER);
//
}
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
void gobutton_actionPerformed(ActionEvent e) { // 输入地址后响应button "Go"
try {
jEditorPane.setPage(textFieldURL.getText()); // 显示URL
//错误,无法解析jEditorPane
} catch (IOException ex) {
JOptionPane msg = new JOptionPane();
JOptionPane.showMessageDialog(this, "URL地址不正确:"
+ textFieldURL.getText(), "输入不正确!", 0);
}
}
}
为什么在方法gobutton_actionPerformed(ActionEvent e)中无法解析jEditorPane?
谢谢!