Last active
June 21, 2021 17:48
-
-
Save erictroebs/6580036cf3b0335437b4bff7f26e70b8 to your computer and use it in GitHub Desktop.
comparison between default and monospaced font in Java Swing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
public class SetFontMonospaced { | |
public static final String TEXT = " A C G T\nA * - - -\nC - * - -\nG - - * -\nT - - - *"; | |
public static void main(String[] args) { | |
for (int i = 1; i <= 2; i++) { | |
JFrame frame = new JFrame("Fenster " + i); | |
frame.setSize(640, 360); | |
JTextPane textPane = new JTextPane(); | |
textPane.setText(TEXT); | |
if (i == 2) { | |
textPane.setFont(Font.getFont(Font.MONOSPACED)); | |
} | |
frame.add(textPane); | |
frame.setVisible(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment