相关疑难解决方法(0)

Java2D OpenGL 图形加速不起作用

我想将 Swing 与 Java2D OpenGL 图形加速一起使用。然而,它不起作用。

我自己回答了这个问题,因为我寻找解决方案很长一段时间。

这是我的代码:

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class OpenGLTest {
    public static void main(String[] args) throws ClassNotFoundException,
            InstantiationException, IllegalAccessException,
            UnsupportedLookAndFeelException {
        // set system look and feel
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        // activate opengl
        System.setProperty("sun.java2d.opengl", "true");

        // create and show the GUI in the event dispatch thread
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                createAndShowGUI();
            }
        });
    }

    private static void createAndShowGUI() {
        JFrame frame = new JFrame();
        frame.setTitle("OpenGL Test");
        frame.setSize(400, 300); …
Run Code Online (Sandbox Code Playgroud)

java opengl swing look-and-feel

4
推荐指数
1
解决办法
4436
查看次数

标签 统计

java ×1

look-and-feel ×1

opengl ×1

swing ×1