need help with javadocs

B

bilsch

Several times I've visited Oracle site to browse the class library
documentation but I never come away with information that satisfied my
curiosity. Here's an example. If someone leads me through this example
it may get me moving through javadocs successfully.

EXAMPLE:
I have a book with the following a statement:
Font f = new Font("TimesRoman", Font.Bold, 36);
The book says that Font is from the java.awt package. I understand what
the statement does, but I don't know where to find a list of the
parameters that Font can work with, for instance I would assume
("CourierNew", Font.Italic, 12) will work, but where is this information
listed? Even more important, where will the documentation tell me what
kind of information goes in the =new Font(a, b, c) part of the
statement. Instead of a, b and c why not w, x, y and z? Where does the
documentation tell me the kind and number of parameters that go inside
the parentheses in Font f = new Font()?

TIA Bill S.
 
A

Arne Vajhøj

Several times I've visited Oracle site to browse the class library
documentation but I never come away with information that satisfied my
curiosity. Here's an example. If someone leads me through this example
it may get me moving through javadocs successfully.

EXAMPLE:
I have a book with the following a statement:
Font f = new Font("TimesRoman", Font.Bold, 36);
The book says that Font is from the java.awt package. I understand what
the statement does, but I don't know where to find a list of the
parameters that Font can work with, for instance I would assume
("CourierNew", Font.Italic, 12) will work, but where is this information
listed? Even more important, where will the documentation tell me what
kind of information goes in the =new Font(a, b, c) part of the
statement. Instead of a, b and c why not w, x, y and z? Where does the
documentation tell me the kind and number of parameters that go inside
the parentheses in Font f = new Font()?

????

http://docs.oracle.com/javase/6/docs/api/java/awt/Font.html#Font(java.lang.String, int, int)

has plenty of information.

Arne
 
D

Daniel Pitts

Several times I've visited Oracle site to browse the class library
documentation but I never come away with information that satisfied my
curiosity. Here's an example. If someone leads me through this example
it may get me moving through javadocs successfully.

EXAMPLE:
I have a book with the following a statement:
Font f = new Font("TimesRoman", Font.Bold, 36);
The book says that Font is from the java.awt package. I understand what
the statement does, but I don't know where to find a list of the
parameters that Font can work with, for instance I would assume
("CourierNew", Font.Italic, 12) will work, but where is this information
listed? Even more important, where will the documentation tell me what
kind of information goes in the =new Font(a, b, c) part of the
statement. Instead of a, b and c why not w, x, y and z? Where does the
documentation tell me the kind and number of parameters that go inside
the parentheses in Font f = new Font()?

TIA Bill S.
If you do a google search for 'java.awt.font 1.6', you'll likely come
across this page:

docs.oracle.com/javase/6/docs/api/java/awt/Font.html

This is the javadoc for Font. It includes details for the Font
constructor (which is what you were looking at).

HTH,
Daniel.
 
S

Stefan Ram

bilsch said:
I understand what the statement does, but I don't know where
to find a list of the parameters that Font can work with

In the documentation of »java,awt,Font«, see »Constructor Summary«.
Also, read Java textbooks about instance creation expressions (JLS 15.9).
 
M

Martin Gregorie

Several times I've visited Oracle site to browse the class library
documentation but I never come away with information that satisfied my
curiosity. Here's an example. If someone leads me through this example
it may get me moving through javadocs successfully.

EXAMPLE:
I have a book with the following a statement:
Font f = new Font("TimesRoman", Font.Bold, 36);
The book says that Font is from the java.awt package. I understand what
the statement does, but I don't know where to find a list of the
parameters that Font can work with, for instance I would assume
("CourierNew", Font.Italic, 12) will work, but where is this information
listed? Even more important, where will the documentation tell me what
kind of information goes in the =new Font(a, b, c) part of the
statement. Instead of a, b and c why not w, x, y and z? Where does the
documentation tell me the kind and number of parameters that go inside
the parentheses in Font f = new Font()?
Its available from the Oracle Java downloads page. The 'Documentation'
tab lets you access an online copy and see what the main Java Library
Javadocs look like. You can also download and install a local copy from
the 'Downloads' tab - its at the bottom of the page in the 'Additional
Resources' table. I think its worth having a local copy, but it is big -
last time I made the comparison the documentation download was bigger
than the matching Java SE JDK download.
 
J

John B. Matthews

bilsch <[email protected]> said:
I understand what the statement does, but I don't know where to find
a list of the parameters that Font can work with. For instance. I
would assume ("CourierNew", Font.Italic, 12) will work, but where is
this information listed?

The documentation for java.awt.Font addresses this issue by
distinguishing between physical and logical fonts. The former have
particular names and availability, while the latter have been mapped to
installed fonts on a given platform.

Rather than "Courier", consider the implementation's monospaced font:

Font f = new Font(Font.MONOSPACED, Font.Italic, 12);

For larger point sizes, consider the available sans serif font:

Font f = new Font(Font.SANS_SERIF, Font.Bold, 36);

Also, be aware of the several variations of deriveFont().

More details may be found in the tutorial:

<http://docs.oracle.com/javase/tutorial/2d/text/fonts.html>
 
L

Lew

John said:
The documentation for java.awt.Font addresses this issue by
distinguishing between physical and logical fonts. The former have
particular names and availability, while the latter have been mapped to
installed fonts on a given platform.

Rather than "Courier", consider the implementation's monospaced font:

Font f = new Font(Font.MONOSPACED, Font.Italic, 12);

For larger point sizes, consider the available sans serif font:

Font f = new Font(Font.SANS_SERIF, Font.Bold, 36);

Also, be aware of the several variations of deriveFont().

More details may be found in the tutorial:

<http://docs.oracle.com/javase/tutorial/2d/text/fonts.html>

Picking up on this, and repeating some of what those references try to teach,
the actual fonts on any given system vary. Just like you might or might not
find a particular file on any given hard drive, you might or might not find a
particular font there.

The physical fonts to which John alludes are the uncertain ones, though many
such as "Courier" are so widespread as to be fairly reliable. The logical
fonts are the ones Java guarantees to be present, but you might find them dull
and boring.

If you want to play with physical fonts you'll need some means of what's
called "discovery" - a way for the software to read the system or some
configuration to find out what's there.

You should have the Javdocs bookmarked and refer to them often.

As in many times a day.
 
J

Jukka Lahtinen

Lew said:
If you want to play with physical fonts you'll need some means of what's
called "discovery" - a way for the software to read the system or some
configuration to find out what's there.

...and when you (the OP) read the javadoc documentation of the
constructor Font(String, int, int) you should find there a "See also"
link that tells you how to do that.
 
R

Roedy Green

The book says that Font is from the java.awt package.

1. Try looking up the puzzling word or class in the Java glossary.
If you don't find it, complain to me. See
http://mindprod.com/jgloss/jgloss.html in this case "Font". It will
tell a newbie all the important things to know about Font, with some
sample code. It will also tell you how to acquire and install fonts.
Under "learning more" It will also provide you a link both to Oracle's
JavaDoc for the Font class and to a local copy, provided you have put
the download in
J:\Program Files\java\jdk1.7.0_04\docs
To get the documentation download see
http://mindprod.com/jgloss/jdk.html
You can put it on E: for example, and set up a J: alias. See
http://mindprod.com/jgloss/jdrive.

2. go to
http://docs.oracle.com/javase/7/docs/api/allclasses-noframe.html
Find the class you want. You don't need to know the package.
Make a bookmark

3. go to
http://docs.oracle.com/javase/7/docs/api/overview-summary.html
find the package you want. Look for the class inside that. Look for
the constructor and methods inside that.
Make a bookmark.

If you lose these bookmarks, look up either class or package in the
Java glossary and look under "Learning More".

--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 
R

Roedy Green

The documentation for java.awt.Font addresses this issue by
distinguishing between physical and logical fonts. The former have
particular names and availability, while the latter have been mapped to
installed fonts on a given platform.

You can fairly easily roll your own fancier logical fonts.
see
https://wush.net/websvn/mindprod/fi...&path=/com/mindprod/common11/FontFactory.java

You figure out which platform, you have, what fonts are available, and
decide on a set of fonts to use as your basic set. This way they can
be a little more interesting than the logical fonts.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top