Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

java - JOptionPane not displaying correctly?

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

Program 1

Program 2

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

image

Console:

42

Code:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...