我写了一个小程序,可能会显示一个消息对话框:
JOptionPane.showMessageDialog(null, "My message", "My title", JOptionPane.PLAIN_MESSAGE);
如果我从控制台启动它,则会因分段错误而崩溃。我尝试了Java 1.6和1.7(这里没有更新的版本),我在具有双显示器设置的Unix工作站上工作。
这是堆栈跟踪:
Stack: [0xb4f30000,0xb4fb0000], sp=0xb4faf3a8, free space=508k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0xb4ae38a8
j sun.awt.X11GraphicsEnvironment.getXineramaCenterPoint()Ljava/awt/Point;+1237795392
j sun.awt.X11GraphicsEnvironment.getXineramaCenterPoint()Ljava/awt/Point;+0
j sun.awt.X11GraphicsEnvironment.getCenterPoint()Ljava/awt/Point;+7
j java.awt.Window.setLocationRelativeTo(Ljava/awt/Component;)V+94
j javax.swing.JOptionPane.initDialog(Ljavax/swing/JDialog;ILjava/awt/Component;)V+77
j javax.swing.JOptionPane.createDialog(Ljava/awt/Component;Ljava/lang/String;I)Ljavax/swing/JDialog;+74
j javax.swing.JOptionPane.showOptionDialog(Ljava/awt/Component;Ljava/lang/Object;Ljava/lang/String;IILjavax/swing/Icon;[Ljava/lang/Object;Ljava/lang/Object;)I+58
j javax.swing.JOptionPane.showMessageDialog(Ljava/awt/Component;Ljava/lang/Object;Ljava/lang/String;ILjavax/swing/Icon;)V+9
j javax.swing.JOptionPane.showMessageDialog(Ljava/awt/Component;Ljava/lang/Object;Ljava/lang/String;I)V+5
我该如何避免这种情况?
谢谢!