File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to use APIs - really dumb question! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to use APIs - really dumb question!" Watch "how to use APIs - really dumb question!" New topic
Author

how to use APIs - really dumb question!

Jinny Morris
Ranch Hand

Joined: Apr 29, 2007
Posts: 101
I haven't asked this before because it felt like I really should be able to figure it out for myself - but I haven't!

I downloaded the Sun Java API so I could access it quickly. It seems that I read somewhere that the API was searchable. HOW? For example, if I want to find the Font class, I scroll down the "all classes" list looking for something that resembles "Font". Surely there's a better way? Even if I don't know which package Font might be in?

Thanks!

PS - And, while I'm at it, how do I find the "constant value" names that can be used to refer to different fonts?
[ September 13, 2007: Message edited by: Jinny Morris ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Look at the top of the main page and you'll see an "Index" link. (In fact I think every page has this link.) Click on that, then choose the "F" page and you'll find the Font class there.

In the docs for the Font class you'll see all the constants like Font.BOLD in the "Fields" section.
Jinny Morris
Ranch Hand

Joined: Apr 29, 2007
Posts: 101
Thank you! It works beautifully!

The reason for the second question is this: in Just Java 2, van der Linden presents a program which scrolls text around on the screen. The font constructor he uses is:

I'm wondering where I can find that "TimesRoman" is a legitimate font name, and what other "standard" font names I can use. I've tried wandering around various constant values in the API but can't find a list of specific font names that can be used.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You can use any font that's installed in the system where the application is running. Obviously Sun can't know about every font that anyone has ever written, so it can't provide the list you are asking for.

The API documentation for the Font class says this:
The getAllFonts method of the GraphicsEnvironment class returns an array of all font faces available in the system.
That might be of some help in your application.
Jinny Morris
Ranch Hand

Joined: Apr 29, 2007
Posts: 101
Ah ... Thank you! Should have tried that - I was lazily looking for an easier way!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use APIs - really dumb question!