According to the spec for Toolkit.isFrameStateSupported(int state): Throws: HeadlessException - if GraphicsEnvironment.isHeadless() returns true. But when running the following code in Headless environment, the method doesn't throw HeadlessException: ======================================================================= import java.awt.*; public class MyHeadlessTest { public void case1() { try { Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.ICONIFIED); } catch (HeadlessException e) { if (GraphicsEnvironment.isHeadless()) { System.out.println("OKAY: headless thrown correctly"); return; } else { System.out.println("headless thrown incorrectly"); return; } } if (GraphicsEnvironment.isHeadless()) { System.out.println("Failed: HeadlessException is not thrown in Headless environment"); return; } System.out.println("OKAY"); } public static void main(String[] args) { MyHeadlessTest t = new MyHeadlessTest(); t.case1(); } } ======================================================================= I was running the code with the following command on Solaris: java -Djava.awt.headless=true MyHeadlessTest And the result of running the above code is: Failed: HeadlessException is not thrown in Headless environment Problem happens on both the Solaris and Linux, and on both the J2SE 1.4.2 and J2SE 1.5. ###@###.### 2005-05-19 22:19:19 GMT
|