代码行出现错误。我应该导入什么?

发布于 2025-01-07 00:11:34 字数 1016 浏览 3 评论 0原文

我收到第 20 行错误(已标记) 对于 .createGLCanvas,我收到一条错误消息“对于 GLDrawableFactory 类型未定义方法 createGLCanvas(GLCapability)”,这是什么意思?我没有导入我应该导入的东西吗?

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.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import java.awt.Canvas;
import javax.swing.JPanel;


public class Forest{//open forest

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

20:    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
    frame.add(canvas);

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

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

    frame.show(); 

}//close forest
}

im getting an error for line 20(labeled) For .createGLCanvas i get an error saying " The method createGLCanvas(GLCapabilities) is undefined for the type GLDrawableFactory" What does this mean? Did i not import something i was suppose to import?

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.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import java.awt.Canvas;
import javax.swing.JPanel;


public class Forest{//open forest

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

20:    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
    frame.add(canvas);

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

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

    frame.show(); 

}//close forest
}

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

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

发布评论

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

评论(3

邮友 2025-01-14 00:11:34

这意味着 GLDrawableFactory。所以你需要弄清楚该调用什么。

It means there is no method called createGLCanvas on GLDrawableFactory. So you need to figure out what to call.

风苍溪 2025-01-14 00:11:34

重点是根据 javadoc 应该支持此方法:

GLCanvas createGLCanvas(GLCapabilities)

我认为您应该再次检查您的类路径。你正在使用什么罐子?你是从哪里下载的? jar版本是什么?检查所有这些,并在编写代码时使用描述您的库版本的适当 API 文档。

The point is that according to javadoc this method should be supported:

GLCanvas createGLCanvas(GLCapabilities capabilities)

I think that you should check again your classpath. What jar are you working with? Where have you downloaded it from? What is the jar version? Check all this and use appropriate API doc that describes your version of the library when you are writing code.

很酷不放纵 2025-01-14 00:11:34

根据此线程,现在执行此操作的正确方法是GLCanvas 画布 = new GLCanvas();。这似乎代表了 API 的变化。

According to this thread, the correct way to do this is now GLCanvas canvas = new GLCanvas();. This seems to represent an API change.

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