对话框根据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);
}
}
答案 0 :(得分:1)
以下是我运行代码(1和5)的结果:
所以必须有别的东西。您确定您的班级文件是最新的吗?