本文介绍了JOptionPane无法正确显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我将我的jdk和docs从7更新到8.我对我的程序进行了一些更改,现在当我尝试让程序使用JOptionPane,JLabel,......时,一切都搞砸了。我创建了一个单独的测试器类,其唯一目的是运行单个JOptionPane框,但仍然出现错误。下面是对话框的外观图片。 Java 8是否存在严重问题?

Today I updated my jdk and docs from 7 to 8. I made a few changes to my program, and now when I try to have the program use JOptionPane, JLabel, ..., everything messes up. I made a separate tester class whose sole purpose is to run a single JOptionPane box and the error still occurred. Below is a picture of what the dialog box looks like. Is there something seriously wrong with Java 8?

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.它可以帮助你确定明显的回归。

For reference, here's a complete example that shows no regression on Mac OS X 10.9, Java 8. It may help you pin down the apparent regression.

附录:在有用的评论中,@ mKorbel引用了使用某些NVIDIA卡在Windows上使用Java 8的类似问题数量。

Addendum: In helpful comments, @mKorbel cites a number of similar problems with Java 8 on Windows with certain NVIDIA cards.

控制台:

42

代码:

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);
            }
        });
    }
}

这篇关于JOptionPane无法正确显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!