home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Sams Teach Yourself Visual J++ 6 in 21 Days
(Publisher: Macmillan Computer Publishing)
Author(s): Rick Leinecker
ISBN: 0672313510
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Q How do you set the font for a Visual J++ Windows application control?

A Make sure that the control is selected (you’ll see the heavy border around it when it is). Find the font property in the Properties window, and click the button on the right side of the field. A file selector will appear. Use the file selector to determine the font that the control will use.

Q How can changing fonts enhance your programs?

A If your program uses the same font as every other program, it’s boring for a user. It’s also not going to necessarily communicate what you want to communicate. For instance, some programs cry out for large, bold text. Examples of this are programs that issue warnings to users—you want warnings to stand out. Color also helps you communicate with users. Red tells readers to pay special attention, whereas soft yellow tends to blend in and be less obtrusive.

Q Why not just use Label controls instead of drawing with text and changing the font?

A Label controls don’t give you much control. It’s hard to move them around in the window, and harder to center them in the window. All around, drawing with methods such as drawString() and drawChars() gives you far greater control than just adding a label to your program.

Review Exercises

1.  Create a simple applet and add a paint() method. Inside the paint() method, create a new font. Select the font into the Graphics class with the setFont() method. Then draw a string to the program’s window. Compile and run the program. Experiment with different fonts.
2.  Create a new applet and add a paint() method. Inside the paint() method, create three fonts. Create them with different attributes. Try giving one a style of Font.PLAIN, one a style of Font.ITALIC, and one a style of Font.BOLD. Create all three with different sizes. Then create three Color classes and make sure that their colors will be clearly different. Draw three strings to the window. Before drawing the first string, select the first font and the first color. Before drawing the second string, select the second font and the second color. Before drawing the third string, select the third font and the third color.
3.  Create a new application. Add three labels to the form. Change the text of the labels to something other than the default label1, label2, and label3 text. Then set the font for each label to something different. Compile and run the program.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.