Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JOptionPane未正确显示?_Java_Swing_Joptionpane - Fatal编程技术网

Java JOptionPane未正确显示?

Java JOptionPane未正确显示?,java,swing,joptionpane,Java,Swing,Joptionpane,今天我将jdk和文档从7更新到8。我对我的程序做了一些更改,现在当我试图让程序使用JOptionPane、JLabel等时,一切都搞砸了。我创建了一个单独的tester类,其唯一目的是运行单个JOptionPane框,但错误仍然发生。下面是该对话框的外观图片。Java8有严重的问题吗 import javax.swing.JOptionPane; public class CirclePointTester { public static void main(String []

今天我将jdk和文档从7更新到8。我对我的程序做了一些更改,现在当我试图让程序使用JOptionPane、JLabel等时,一切都搞砸了。我创建了一个单独的tester类,其唯一目的是运行单个JOptionPane框,但错误仍然发生。下面是该对话框的外观图片。Java8有严重的问题吗

import javax.swing.JOptionPane;



public class CirclePointTester
 {
    public static void main(String [] args)
    {
        String input = JOptionPane.showInputDialog("Enter the x coordinate of the circle");
            int xc = Integer.parseInt(input);
        String input2 = JOptionPane.showInputDialog("Enter the y coordinate of the circle");
            int yc = Integer.parseInt(input2);
        String input3 = JOptionPane.showInputDialog("Enter the height value of the circle");
            int height = Integer.parseInt(input3);
        String input4 = JOptionPane.showInputDialog("Enter the width value of the circle");
            int width = Integer.parseInt(input4);
    }
 }


作为参考,这里有一个完整的示例,显示在Mac OS X 10.9和Java 8上没有回归。它可以帮助你确定明显的回归

附录:在有用的评论中,@mKorbel引用了一个带有某些NVIDIA卡的Windows上的Java 8

控制台:

42
代码:


最好也共享代码。代码似乎不是问题所在。。。如果有帮助的话,我当前的IDE是JCreator Pro。那么您的操作系统的图形有问题。是的,Java 8可能会导致这个问题。请重新安装。请参阅。尽管大多数情况下没有问题,但使用Swing的正确方法是在事件分派线程的上下文中创建和显示组件,在本例中使用
SwingUtilities.invokeLater()
最新版本存在问题
import java.awt.EventQueue;
import javax.swing.JOptionPane;

/**
 * @see https://stackoverflow.com/a/24875960/230513
 */
public class Test {

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String input = JOptionPane.showInputDialog(
                    "Enter the x coordinate of the circle");
                int xc = Integer.parseInt(input);
                System.out.println(xc);
            }
        });
    }
}