arestivo

Untitled

Feb 26th, 2021
811
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×