1

该对话框根据ASCII显示前面一个字符的所有内容,在通过dos运行程序时遇到同样的问题。

请有人帮帮我!

import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.UIManager;

class MyFirstGUI {
    public static void main(String[] args) {

        JDialog.setDefaultLookAndFeelDecorated(true);
        System.out.println(UIManager.getLookAndFeel().getName());
        String first = JOptionPane.showInputDialog("Enter the first number");
        String second = JOptionPane.showInputDialog("Enter the second number");

        int n = Integer.parseInt(first);
        int m = Integer.parseInt(second);
        int sum = n + m;

        JOptionPane.showMessageDialog(null, "sum = "+sum, "Sum of 2 numbers", JOptionPane.PLAIN_MESSAGE);

    }  
}
4

1 回答 1

1

Here is what I get from running your code (with 1 and 5):

Step 1

Step 2

Step 3

So there must be something else. Have you make sure that your class files are up-to-date?

于 2012-10-08T18:48:30.120 回答