点击" Play"我收到间歇性错误我的游戏按钮。
有时它可以正常工作并开始游戏,其他时候它会停止运行游戏并抛出此错误:
Exception in thread "main" java.lang.InternalError: couldn't create component peer
at sun.awt.windows.WComponentPeer.checkCreation(Unknown Source)
at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
at sun.awt.windows.WCanvasPeer.<init>(Unknown Source)
at sun.awt.windows.WPanelPeer.<init>(Unknown Source)
at sun.awt.windows.WWindowPeer.<init>(Unknown Source)
at sun.awt.windows.WFramePeer.<init>(Unknown Source)
at sun.awt.windows.WToolkit.createFrame(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at Joehot200.TerrainDemo.setUpDisplay(TerrainDemo.java:3363)
at Joehot200.TerrainDemo.startGame(TerrainDemo.java:3434)
at StartScreenExperiments.Test2.resartTDemo(Test2.java:55)
at StartScreenExperiments.Test2.main(Test2.java:41)
SetUpDisplay()中的第3363行是:
frame = new JFrame();
Canvas canvas = new Canvas();
frame.add(canvas);
frame.setDimensions(50, 50);
frame.setVisible(true); //This is line 3363
try {
Display.setParent(canvas);
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
我找不到解决方法。特别是因为错误是间歇性的,并且不能总是重现。