X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fio%2FSwingScreen.java;h=ee8467dd076008970784d1225609f516cbc9a469;hb=c447c6e5759db7ac9bbb05cc1b3618dd38230335;hp=24b007a3040cf1a79db1d6d146e2ee0138025b38;hpb=15364867da403c8fa9e82ea5c5bf53413efc39cc;p=fanfix.git diff --git a/src/jexer/io/SwingScreen.java b/src/jexer/io/SwingScreen.java index 24b007a..ee8467d 100644 --- a/src/jexer/io/SwingScreen.java +++ b/src/jexer/io/SwingScreen.java @@ -308,8 +308,10 @@ public final class SwingScreen extends Screen { * Public constructor. * * @param screen the Screen that Backend talks to + * @param fontSize the size in points. Good values to pick are: 16, + * 20, 22, and 24. */ - public SwingFrame(final SwingScreen screen) { + public SwingFrame(final SwingScreen screen, final int fontSize) { this.screen = screen; setDOSColors(); @@ -342,13 +344,13 @@ public final class SwingScreen extends Screen { getContextClassLoader(); InputStream in = loader.getResourceAsStream(FONTFILE); Font terminusRoot = Font.createFont(Font.TRUETYPE_FONT, in); - Font terminus = terminusRoot.deriveFont(Font.PLAIN, 20); + Font terminus = terminusRoot.deriveFont(Font.PLAIN, fontSize); setFont(terminus); gotTerminus = true; } catch (Exception e) { e.printStackTrace(); // setFont(new Font("Liberation Mono", Font.PLAIN, 24)); - setFont(new Font(Font.MONOSPACED, Font.PLAIN, 24)); + setFont(new Font(Font.MONOSPACED, Font.PLAIN, fontSize)); } pack(); @@ -742,16 +744,24 @@ public final class SwingScreen extends Screen { /** * Public constructor. + * + * @param windowWidth the number of text columns to start with + * @param windowHeight the number of text rows to start with + * @param fontSize the size in points. Good values to pick are: 16, 20, + * 22, and 24. */ - public SwingScreen() { + public SwingScreen(final int windowWidth, final int windowHeight, + final int fontSize) { + try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - SwingScreen.this.frame = new SwingFrame(SwingScreen.this); + SwingScreen.this.frame = new SwingFrame(SwingScreen.this, + fontSize); SwingScreen.this.sessionInfo = new SwingSessionInfo(SwingScreen.this.frame, - frame.textWidth, - frame.textHeight); + frame.textWidth, frame.textHeight, + windowWidth, windowHeight); SwingScreen.this.setDimensions(sessionInfo.getWindowWidth(), sessionInfo.getWindowHeight());