• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.awt.GraphicsEnvironment.isHeadless() - works wrong Linux env.  RSS feed

 
Andrey Galimshyn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to All,

I can't understand why when display is set "isHeadless()" returns "true" and vice versa.
Some people do something like that:


public static boolean isHeadless() {
// it still may be the case that there is no graphics environment
// available. In that case creating a dialog will fail.
try {
javax.swing.JDialog d = new javax.swing.JDialog();
d.dispose();
return false;
} catch (java.lang.NoClassDefFoundError e) {
return true;
} catch (java.awt.HeadlessException e) {
return true;
} catch (java.lang.InternalError e) {
return true;
}
}

but I don't like it very much((((
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's wrong with plain old "GraphicsEnvironment.isHeadless()"?

Moving to the AWT / Swing forum.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!