JOGL框架未显示+错误

时间:2014-08-06 11:29:10

标签: java jogl

我有以下代码,但无效:

import net.java.games.jogl.*;

import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class Game {



    public static void main(String[] args) {
            // TODO Auto-generated method stub

            Frame frame = new Frame("Hello World");
            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();



    }

}

第一次导入有一个错误,它无法识别“net”是什么。错误如下:

无法解析导入网

尝试运行程序时出现完整错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
GLCapabilities cannot be resolved to a type
The method add(Component) in the type Container is not applicable for the arguments (GLCanvas)at Game.main(Game.java:15)

1 个答案:

答案 0 :(得分:0)

你使用的是JOGL的旧版本,自2007年(至少)以来已经完全过时了.Marco13是对的。请切换到JOGL 2(当前最新版本:2.2.0)并按照以下说明操作: http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE