swing - Java custom font -
As stated with the title, how do I set a custom font? I have already tried to enter the font in the graphical environment, setting up the getResourceAsStream method and a file inputstream to load four, but it still does not work. After searching through Stackoverflow on many similar queries, it has been said that I just need to set up a getResourceAsstream method and register the font and it will load. I can not help after asking questions and getting answers, but I can get it for a while. I used this method:
create the font to make // to create a font. Specify the size! InputStream Custom = New FileInputStream ("C: / Users / HP / Document / Netbeen Project / PentiumMmer / SRC / ProVi / Fonts / Quickers Light-Regular .tft"); Font customfonts = font.create font (font .truetype_font, custom) .deriveFont (12f); Graphics Environment Ge = Graphics Environment. GateLocal Graphics Environment (); // font ge.registerFont (font .createFont (font. TRUETYPE_FONT, custom)) Register; MainMenuTitle.setFont (customFont); } Hold (IOException e) {e.printStackTrace (); } Hold (font format expansion e) {e.printStackTrace (); }
The font folder is located in a separate package, any answer? Edit: This is called javfox in swing
Comments
Post a Comment