'Programmatically check OpenGL support

My swing application is trying to use OpenGL to get better performance. But on some machines the UI doesnt load at all. How could i determine programmatically if OpenGl is supported so i could switch between xrenderer/OpenGL?

xrenderer works fine on all machines ive tested but id rather use OpenGL

This is what im using to enabled OpenGL

System.setProperty("sun.java2d.opengl","True");

This is what i get on the console: "OpenGL pipeline enabled for default config on screen 1". I think this means that OpenGL is on, but the UI components wont load and the screen is white. I can still click on the invisible buttoms though. blankApp
(source: i.ibb.co)

EDIT: Sort of figured out the problem, OpenGL is enabled on screen 1 but not on screen 0. I dont know how to force it to be enabled on both 0 and 1. Disconnecting the second display caused OpenGL to bve enabled on screen 0, but this did not help and the app is still blank



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source