Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
Jan 12, 2000



See Which Fonts Are Installed With Your VM

Sometimes, it is useful to know which fonts are installed. This can differ from one Java Virtual Machine (JVM) implementation to another. The following code displays the names of all the fonts available on a particular JVM on the drawing context of a JLabel.
        String [] fonts = getToolkit().getFontList(); 
        Font font; 
        int font_size = 12; 
        int x = 20; 
        int y = 25; 
        int lineSpacing = 25;        
        Graphics g = JLabel1.getGraphics(); 
        //JLabel1 is a javax.swing.JLabel already defined, 
        // and positioned on your GUI 
        for (int i = 0; i < fonts.length; i++) 
            font = new Font(fonts[i], Font.BOLD, font_size); 
            g.drawString(fonts[i], x, y); 
            y += lineSpacing; 
Behrouz Fallahi
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date