/** * From https://java3d.dev.java.net/issues/show_bug.cgi?id=89 Finds the preferred <code> * GraphicsConfiguration</code> object for the system. This object can then be used to create the * Canvas3D object for this system. * * @param window the window in which the Canvas3D will reside * @return The best <code>GraphicsConfiguration</code> object for the system. */ private static GraphicsConfiguration getPreferredConfiguration(Window window) { if (window == null) return SimpleUniverse.getPreferredConfiguration(); GraphicsDevice device = window.getGraphicsConfiguration().getDevice(); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); String stereo; // Check if the user has set the Java 3D stereo option. // Getting the system properties causes appletviewer to fail with a // security exception without a try/catch. stereo = (String) java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Object run() { return System.getProperty("j3d.stereo"); } }); // update template based on properties. if (stereo != null) { if (stereo.equals("REQUIRED")) template.setStereo(GraphicsConfigTemplate.REQUIRED); else if (stereo.equals("PREFERRED")) template.setStereo(GraphicsConfigTemplate.PREFERRED); } // Return the GraphicsConfiguration that best fits our needs. return device.getBestConfiguration(template); }