|
|||
|
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. |
|
|
||||
|
||||
|
|
|
|||
|
On 4/28/2012 7:25 PM, bilsch wrote:
> 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...0int,%20int%29 has plenty of information. Arne |
|
|||
|
On 4/28/12 4:25 PM, bilsch wrote:
> 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. |
|
|||
|
bilsch <king621@comcast.net> writes:
>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). |
|
|||
|
In article <jnhu9t$19n$1@dont-email.me>, bilsch <king621@comcast.net>
wrote: > 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> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews> |
|
|||
|
John B. Matthews wrote:
> bilsch wrote: >> 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> 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. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg |
|
|||
|
On 4/28/2012 9:14 PM, Lew wrote:
.... > You should have the Javdocs bookmarked and refer to them often. > > As in many times a day. > Change that to "per hour" the first time you write code using a particular API area. Patricia |
|
|||
|
Lew <noone@lewscanon.com> writes:
> 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. -- Jukka Lahtinen |
|
|||
|
On Sat, 28 Apr 2012 16:25:48 -0700, bilsch <king621@comcast.net>
wrote, quoted or indirectly quoted someone who said : >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...s-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...w-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. .. |
|
|||
|
On Sun, 29 Apr 2012 00:10:31 -0400, "John B. Matthews"
<nospam@nospam.invalid> wrote, quoted or indirectly quoted someone who 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. You can fairly easily roll your own fancier logical fonts. see https://wush.net/websvn/mindprod/fil...ntFactory.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. .. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|