2014-03-19 4 views
0

현재 작업중인 프로젝트에서 Helvetica 글꼴을 사용해야합니다. Netbeans에서는 GUI에서 해당 글꼴을 사용할 수있는 옵션이 없지만 어떻게 가져올 수 있습니까?Netbeans에 글꼴 가져 오기

답변

1

이 시도 :

 You can SetFont for component using font class 
     Font f=new Font("Helvetica",Font.BOLD,20); 
     setFont(JComponent); 

또는 사용을 :

public class FontLoader { 

    public static Font loadFont(float size, int style, JLabel j) { 
    Font font = null; 
    InputStream is = j.getClass().getResourceAsStream("starv___.ttf"); 
    try { 
     font = Font.createFont(Font.TRUETYPE_FONT, is); 
     font = font.deriveFont(size); 
     font = font.deriveFont(style); 
    } /*catch (FileNotFoundException fe) { 
     System.out.println("File not found"); // was in here because i tried a file  instead of an InputStream 
    } */catch (FontFormatException ex) { 
     System.out.println("Font is null1"); 
    } catch (IOException e) { 
     System.out.println("Font is null2"); 
    } 
    return font; 
} 
} 
관련 문제