This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • 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: 21092
85
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!