crash - JOptionPane 在随机运行次数后停止(在 MacbookAir 上使用 Eclipse Kepler、java 7、Windows 7 64 位)

标签 crash windows-7-x64 joptionpane halt eclipse-kepler

我已经彻底研究过这个问题,但没有用。希望你们能帮助我。预先非常感谢!

测试代码如下:

import javax.swing.JOptionPane;
public class JOptionPane_Test {
    public static void main(String[] args){
        String userExit="a";
        while (userExit!=null){
            userExit = JOptionPane.showInputDialog(null, "Message");
        }
    }
}

它只是显示一个等待用户响应的输入框,如果用户点击“确定”则重复,如果用户点击“取消”或“X”按钮则停止。在按随机次数的“确定”(或 Enter 键)后,该框将停止。它只显示框的框架,带有 X 按钮,内部没有任何内容(没有消息,没有输入字段,没有确定或取消按钮)。我唯一能做的就是点击 X 按钮退出程序。

showMessageDialog 和 showInputDialog 都会发生这种情况。

我的日志显示此警告:

!SESSION 2013-07-09 14:00:12.666 ----------------------------------------------- eclipse.buildId=4.3.0.I20130605-2000 java.version=1.7.0_25 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Framework arguments: -product org.eclipse.epp.package.standard.product Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.standard.product

!ENTRY org.eclipse.egit.ui 2 0 2013-07-09 14:00:30.147 !MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory. The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in this system level configuration. The Git installation location can be configured on the Team > Git > Configuration preference page's 'System Settings' tab. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

但我怀疑这个警告与 JOptionPane 错误没有任何关系。还是我错了?

我发现了这个forum有人遇到了与我完全相同的问题,解决方案是检查 Eclipse 使用的编译器,确保它是 Sun 的而不是 GCJ 的。不过,我的一直是Sun的,java 7。

我已经尝试过 64 位和 32 位的 Eclipse。

非常感谢任何帮助!!

最佳答案

我找到了解决办法!!!感谢Nick 我没有使用空父组件,而是将 Pane 添加到框架中,一切正常!这显然是一个 JOptionpane 错误。

修改后的代码:

import javax.swing.*;

public class JOptionPane_Test {
    public static void main(String[] args){
        String userExit="a";
        JFrame frame = new JFrame();
        while (userExit!=null){
            userExit = JOptionPane.showInputDialog(frame, "Message");
        }
    }
}

关于crash - JOptionPane 在随机运行次数后停止(在 MacbookAir 上使用 Eclipse Kepler、java 7、Windows 7 64 位),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17543612/

相关文章:

java - JOptionPane.showConfirmDialog 阻止后台窗口

ios - MPMusicPlayerController和iOS 11.3

ios - 如果我将 CIFilter 应用于 CIImage - Swift 2.0,应用程序会崩溃

python-3.x - 即使在 chromedriver 之后,Chrome 也会随机崩溃

visual-studio-2008 - Visual Studio在Windows 7 64位计算机上找不到CIODMLib项目引用

windows - 如何将我的 perl 脚本打包为 32 位可执行文件?

c++ - 尽管类型在析构函数中完全限定,但 std::auto_ptr 崩溃和泄漏

c - sndfile.h C CodeBlocks Windows 7

java - 在 JOptionPane 中显示 JDateChooser

java - 我的 JPanel 中的 .showMessageDialog 出现错误?