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

发布于 2025-01-07 16:57:31 字数 1248 浏览 3 评论 0原文

我所做的只是运行 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
}
        }
    });

All im trying to is run an AWT and have a window show up. But instead i get a JVM error from eclipse. Error is as follows:

# 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

And here is the actual code that runs the program.

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
}
        }
    });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏雪无痕 2025-01-14 16:57:31

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

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);
    }
}

You seemed to have mixed up your closing brackets. Here's the final code that should work:

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);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文