Hi all, as some of you might know the API is my nightmare. I know it's important and therefore I am trying to use it as much as I can. Today I am looking at a program that uses buttons to change the font of some text.
So, I have this line:
texField.setFont( new Font( "Serif", Font.PLAIN, 14) );
I looked in the API first for the setFont method in http://docs.oracle.com/javase/7/docs/api/javax/swing/JTextField.html and found this:

public void setFont(Font f)
Sets the current font. This removes cached row height and column width so the new font will be reflected. revalidate is called after setting the font.
Overrides:
setFont in class JComponent
Parameters:
f - the new font
See Also:
Component.getFont()

which is great. Then I moved to the Font class http://docs.oracle.com/javase/7/docs/api/java/awt/Font.html but what I was hoping to find was something like new Font(parameter1, parameter2, parameter3) which I did:

public Font(String name,
    int style,
    int size)

but I am not sure this is what I am looking for, and I think this is because of my inability to search throught the API (the second parameter in the code above - Font.PLAIN surely can't be an int!?)
I know this isn't a question as such, more a rant really, but I just find it very difficult to find my way across the API...

oh...and so it is! thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.