Hi,
I am trying to rendering
the 3d view into the image file without any GUI. If I do not extend the
program from an AWT or Swing component, the program will not exit after
processing (so, holds the memory. The rendering result is perfect). =20 Does
any one know how to deal with this?
Here is the sample code
(if you run it in command line, you will see that it will hangs there
forever):
public class
Devicetest{
=20
/**
Creates a new instance of Devicetest */
public
Devicetest() {
GraphicsConfigTemplate3D template =3D new
GraphicsConfigTemplate3D();
=20
GraphicsEnvironment env =3D
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice dev =3D env.getDefaultScreenDevice();
GraphicsConfiguration gc =3D
dev.getBestConfiguration(template);
//...
System.out.println(gc + " " + "End");
=20
}
public static void main(String argv[]) {
Devicetest dd =3D new Devicetest();
}
}
However, the following
works (but extends from Applet):
public class Devicetest
extends Applet{
=20
/**
Creates a new instance of Devicetest */
public
Devicetest() {
GraphicsConfigTemplate3D template =3D new
GraphicsConfigTemplate3D();
=20
GraphicsEnvironment env =3D
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice dev =3D env.getDefaultScreenDevice();
GraphicsConfiguration gc =3D
dev.getBestConfiguration(template);
Canvas3D canvas =3D new Canvas3D(gc, true);
//...
System.out.println(gc + " " + "End");
=20
}
public static void main(String argv[]) {
Frame frame =3D new MainFrame(new Devicetest(), 256, 256);
}
}
Weisheng