desktop: don't show dialogs when headless

experimental^2^2
Kirill Vainer 9 years ago
parent 80af02e1f3
commit 239524c85b
  1. 8
      jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java

@ -43,6 +43,7 @@ import com.jme3.system.JmeContext.Type;
import com.jme3.util.Screenshots; import com.jme3.util.Screenshots;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
@ -116,12 +117,16 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
@Override @Override
public void showErrorDialog(String message) { public void showErrorDialog(String message) {
if (!GraphicsEnvironment.isHeadless()) {
final String msg = message; final String msg = message;
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
ErrorDialog.showDialog(msg); ErrorDialog.showDialog(msg);
} }
}); });
} else {
System.err.println("[JME ERROR] " + message);
}
} }
@Override @Override
@ -129,6 +134,9 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
if (SwingUtilities.isEventDispatchThread()) { if (SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("Cannot run from EDT"); throw new IllegalStateException("Cannot run from EDT");
} }
if (GraphicsEnvironment.isHeadless()) {
throw new IllegalStateException("Cannot show dialog in headless environment");
}
final AppSettings settings = new AppSettings(false); final AppSettings settings = new AppSettings(false);
settings.copyFrom(sourceSettings); settings.copyFrom(sourceSettings);

Loading…
Cancel
Save