【问题标题】:Swing JDialog box appear itself?Swing JDialog 对话框是否出现?
【发布时间】:2011-08-02 20:31:27
【问题描述】:
public Action colorAction = new AbstractAction("Font Color", new ImageIcon(
        getClass().getResource("/img/color.png"))) {
    public void actionPerformed(ActionEvent e) {
        colorB_actionPerformed(e);
    }
};

public void colorB_actionPerformed(ActionEvent e) {
    Color c = JColorChooser.showDialog(getRightPanel(), "Font color",
            Color.CYAN);
    if (c == null)
        return;
    new StyledEditorKit.ForegroundAction("", c).actionPerformed(e);
}

以上是我用来显示颜色选择器对话框的代码。我的问题是,我什至从未开始运行或编译程序。但是颜色选择器对话框会自动出现吗?

public void linkActionB_actionPerformed(ActionEvent e) {
    String value = JOptionPane.showInputDialog(getJPanel(), "Enter URL :");

    String aTag = "<a";
    aTag += " href=\"" + value + "\"";

    aTag += ">" + value + "</a>";
    if (editor.getCaretPosition() == document.getLength())
        aTag += "&nbsp;";
    editor.replaceSelection("");
    try {
        editorKit.insertHTML(document, editor.getCaretPosition(), aTag, 0,
                0, HTML.Tag.A);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

当我还在编码时,显示链接对话框也会自动出现。有什么想法吗?

【问题讨论】:

  • 我使用 Eclipse 可视化编辑器打开它。正常吗,用可视化编辑器打开会自动弹出对话框?因为当我用java编辑器打开它时,不会弹出对话框。

标签: java swing jdialog


【解决方案1】:

是的,我敢打赌,您正在使用某种 IDE,并且您有一些过去运行的实例或调试会话仍然存在。检查并关闭所有正在运行/调试的 JVM,然后重新开始。

【讨论】:

  • 您好,感谢您的回复,我重新启动了eclipse IDE,一旦我打开文件,就会出现对话框,甚至还没有开始运行或编译文件
  • 您是否在某处设置了自动运行?事情不只是运行,必须启动它。
  • 如果在 Windows 中工作,请转到任务管理器并杀死您找到的所有 java 进程。比启动 Eclipse IDE
  • 不,没有任何自动运行,如果打开文件出现对话框,则在重新启动eclipse IDE后已经杀死所有java进程。
  • 转到你的类文件所在的位置,删除它们。它会再次出现吗?比编译重新创建类文件并启动IDE,它现在出现了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-01-31
  • 2012-06-11
  • 1970-01-01
  • 1970-01-01
  • 2011-11-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多