java - 为什么我运行这个程序时没有弹出一个框架?约格尔

标签 java error-handling jogl

我所做的就是运行 AWT 并显示一个窗口。但我却从 Eclipse 中得到了 JVM 错误。错误如下:

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3174), pid=6688, tid=14480
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_20-b02
# Java VM: Java HotSpot(TM) 64-Bit Server VM (16.3-b01 mixed mode windows-amd64 )
# An error report file with more information is saved as:
# C:\xampp\htdocs\android\FireRunn\hs_err_pid6688.log

这是运行该程序的实际代码。

import javax.media.opengl.*;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCapabilities;
public class Forest{//open forest

public static void main(String[] args)
{
    Frame frame = new Frame("Hello World");

    GLCapabilities glcapabilities = new GLCapabilities( );
    GLCanvas glcanvas = new GLCanvas( glcapabilities );
    frame.add(glcanvas );

    frame.setSize(300, 300);
    frame.setBackground(Color.WHITE);

    frame.addWindowListener(new WindowAdapter()
    {
        public void windowClosing(WindowEvent e)
        {
            System.exit(0);

    frame.setVisible(true); 

}//close forest
}
        }
    });

最佳答案

您似乎混淆了右括号。这是应该有效的最终代码:

public class Forest{//open forest

    public static void main(String[] args) {
        Frame frame = new Frame("Hello World");

        GLCapabilities glcapabilities = new GLCapabilities();
        GLCanvas glcanvas = new GLCanvas(glcapabilities);
        frame.add(glcanvas);

        frame.setSize(300, 300);
        frame.setBackground(Color.WHITE);

        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });//close forest
        frame.setVisible(true);
    }
}

关于java - 为什么我运行这个程序时没有弹出一个框架?约格尔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9347086/

相关文章:

python - DataGenerator在Google云端硬盘中找不到文件

java - Eclipse RCP 应用程序依赖关系顺序

java - 在java OpenGL中从屏幕(视口(viewport))导出图像

java - 在Java中将“mm/yy”转换为“yyyy-mm-dd”

java - 内部类的原因

ios - 错误为 "The operation couldn’ 的 NSData 无法完成。 ( cocoa 错误 256。)”

java - 使用 JOGL 进行全屏 Swing

java - 从查询中获取结果作为自定义对象列表

java - 如何在 Spring Data 中将 Java 实体映射到多个 MongoDB 集合?

email - 错误处理-如果网络中断,则循环生成电子邮件的脚本