dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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: Intermediate
Apr 10, 1999

WEBINAR:

On-Demand

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


Obtaining the List of Available Fonts

Some applications allow the user to select which font is used for displaying text. To do this, you need to be able to dynamically determine which fonts are available so that the user can select the one that they wish to use. Fortunately, Java provides a simple way of obtaining this information through the Toolkit class. This method will return a java.awt.Choice instance that is populated with the names of the available fonts:
 
public java.awt.Choice getFontChoice() {
	java.awt.Choice choice = new java.awt.Choice();
	Toolkit tk = Toolkit.getDefaultToolkit();
	String[] fontnames = tk.getFontList();
	for (int i = 0; i < fontnames.length; i++) {
		choice.addItem(fontnames[i]);
	}  //  for (int i = 0; i < fontnames.length; i++)
	return choice;
}  //  public java.awt.Choice getFontChoice()

Brett Spell
 
Comment and Contribute

 

 

 

 

 


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

 

 

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