Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HeadlessException is not caught!

843810Jul 5 2005 — edited May 31 2006
I'm trying to create a method/function to determine if my app can create offscreen images using awt, and thanks to suggestions here in this forum I've been pointed in the direction of headless mode/state.

From what I've gathered: If an unsupported operation is attempted, a HeadlessException is thrown.
Therefore I hoped this would do the trick:
public boolean canDraw()
{
    boolean rv = true;

    try
    {
         Color c = new Color(100,100,100);
    }
    catch (HeadlessException he)
    {
          rv = false;
    }
    
    return rv;
}
But, alas, no HeadlessException is caught, and the app crashes.
Where am I thinking wrong?

Grateful for any help,
/J
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2006
Added on Jul 5 2005
8 comments
298 views