File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Font Chooser JComboBox (RESOLVED) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Font Chooser JComboBox (RESOLVED)" Watch "Font Chooser JComboBox (RESOLVED)" New topic

Font Chooser JComboBox (RESOLVED)

Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Hi all,

Still not 100% certain about what makes a beginner/intermediate/advanced query, so apologies if this is in the wrong place!

Anyway, to the point - I'm trying to make a Word-style drop-down font selection list. I'm guessing that the best option is a JComboBox populated with all the fonts in my system - so the question that I'm asking is: is there a way to get a list of all my fonts?

Any other advice much appreciated!
[ February 20, 2006: Message edited by: David Payne ]
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I knew there must be one, because I wrote one myself. But I wrote it a couple of years ago (so I don't remember what I did) and it's on my home computer. So I quickly checked the documentation for java.awt.Font and after scrolling down a bit I came upon this sentence:

"The getAllFonts method of the GraphicsEnvironment class returns an array of all font faces available in the system."

It goes on to explain what to do with that list, but in any case that's your starting point.
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Splendid, couldn't have hoped for a better answer!

Thanks very much.
I agree. Here's the link:
subject: Font Chooser JComboBox (RESOLVED)
It's not a secret anymore!