Advertisement
arestivo

Untitled

Feb 26th, 2021
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. public class Application {
  2.     public static void main(String[] args) throws IOException, FontFormatException, URISyntaxException {
  3.         new Application().run();
  4.     }
  5.  
  6.     private void run() throws IOException, FontFormatException, URISyntaxException {
  7.         URL resource = getClass().getClassLoader().getResource("square.ttf");
  8.         File fontFile = new File(resource.toURI());
  9.         Font font =  Font.createFont(Font.TRUETYPE_FONT, fontFile);
  10.  
  11.         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  12.         ge.registerFont(font);
  13.  
  14.         DefaultTerminalFactory factory = new DefaultTerminalFactory();
  15.  
  16.         Font loadedFont = font.deriveFont(Font.PLAIN, 25);
  17.         AWTTerminalFontConfiguration fontConfig = AWTTerminalFontConfiguration.newInstance(loadedFont);
  18.         factory.setTerminalEmulatorFontConfiguration(fontConfig);
  19.         factory.setForceAWTOverSwing(true);
  20.         factory.setInitialTerminalSize(new TerminalSize(40, 20));
  21.  
  22.         Terminal terminal = factory.createTerminal();
  23.         ((AWTTerminalFrame)terminal).addWindowListener(new WindowAdapter() {
  24.             @Override
  25.             public void windowClosing(WindowEvent e) {
  26.                 e.getWindow().dispose();
  27.             }
  28.         });
  29.  
  30.         Screen screen = new TerminalScreen(terminal);
  31.         screen.setCursorPosition(null);   // we don't need a cursor
  32.         screen.startScreen();             // screens must be started
  33.         screen.doResizeIfNecessary();     // resize screen if necessary
  34.  
  35.         screen.setCharacter(10, 10, TextCharacter.fromCharacter('C')[0]);
  36.         screen.refresh();
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement