我试图抓住一个异常,然后在JTextArea中显示它,但我得到null ...
这里是:
} catch (Exception rwe) {
// System.exit(0);
game.remove(yPanel);
game.remove(xPanel);
game.remove(roomPanel);
game.remove(userPanel);
game.remove(titlePanel);
game.remove(introPanel);
remove(game);
remove(sp);
remove(invOne);
remove(main);
remove(say);
add(statusPanel);
JTextArea errorText = new JTextArea();
errorText.append("Here is the reason why it crashed:\n" +rwe.getMessage());
errorText.setPreferredSize(new Dimension(500,300));
System.out.println("errorrr:" + rwe.getMessage());
statusPanel.add(errorText);
statusPanel.setOpaque(true);
labelStatus.setVisible(true);
System.out.println("Server crashed");
c.append("\nServer crashed...");
rwe.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
当一个错误发生时,我在JTextArea中得到它:
Here is the reason why it crashed:
null
Run Code Online (Sandbox Code Playgroud)
为什么?
| 归档时间: |
|
| 查看次数: |
4521 次 |
| 最近记录: |