dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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.setFont(font); 
            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