我正在编写一个JDesktopPane应用程序,并且在 a 中JInternalFrame,我JEditorPane打开了一个网页(是的,我知道使用JEditorPane网络的蹩脚能力,不要骂)。
我有一种方法让用户输入他们想要访问的页面,但是当我调用JOptionPane.showInternalInputDialog(this, "What page would you like to visit?")文本字段时不可编辑。我在 Java 6 和 Java 7 中都出现了这个问题。
编辑:这是我班级的构造函数
public Internet() {
    super("Internet", true, true, true, true);
    setSize(500, 400);
    try {
        pane = new JEditorPane(new URL("http://www.vetrustech.tk"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    setContentPane(pane);
    bar = new JMenuBar();
    page = new JMenu("Page");
    enterPage = new JMenuItem("Enter a page");
    bar.add(page);
    page.add(enterPage);
    setJMenuBar(bar);
    enterPage.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            loadPage();
        }
    });
这是加载页面的方法
private void loadPage() {
    String s = JOptionPane.showInternalInputDialog(this,
            "What page are you visiting?");
    if (s == null) {
        return;
    }
    if (s.equals("")) {
        return;
    }
    try {
        URL u = new URL(s);
        pane.setPage(u);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}