devxlogo

See Which Fonts Are Installed With Your VM

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;         } 
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist