X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingTerminal.java;h=f0ba3552fd52b812a91a06be0f97c9adb96604e7;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=7ca80a5573f59eeaf57fa8096ca592acc7770523;hpb=d91ac0f5500f66bc9fa2691883e2e3ed3fe84ad7;p=fanfix.git diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index 7ca80a5..f0ba355 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -821,13 +821,35 @@ public class SwingTerminal extends LogicalScreen * @param font the new font */ public void setFont(final Font font) { - synchronized (this) { - this.font = font; - getFontDimensions(); - swing.setFont(font); - glyphCacheBlink = new HashMap(); - glyphCache = new HashMap(); - resizeToScreen(true); + if (!SwingUtilities.isEventDispatchThread()) { + // Not in the Swing thread: force this inside the Swing thread. + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + synchronized (this) { + SwingTerminal.this.font = font; + getFontDimensions(); + swing.setFont(font); + glyphCacheBlink = new HashMap(); + glyphCache = new HashMap(); + resizeToScreen(true); + } + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (java.lang.reflect.InvocationTargetException e) { + e.printStackTrace(); + } + } else { + synchronized (this) { + SwingTerminal.this.font = font; + getFontDimensions(); + swing.setFont(font); + glyphCacheBlink = new HashMap(); + glyphCache = new HashMap(); + resizeToScreen(true); + } } } @@ -2156,7 +2178,7 @@ public class SwingTerminal extends LogicalScreen * @param mouse mouse event received */ public void mouseEntered(final MouseEvent mouse) { - // Ignore + swing.requestFocusInWindow(); } /**