

The getName() method returns the font's logical name. SetFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 20)) Characteristics If you want underlining, you have to do it manually, with the help of FontMetrics. PLAIN combined with either BOLD or ITALIC represents bold or italic, respectively. The combination BOLD | ITALIC represents a bold italic font. The PLAIN constant represents a plain or normal font. The ITALIC constant represents an italic font. The BOLD constant represents a boldface font. Three class constants are used to represent font styles: There are four styles for displaying fonts in Java: plain, bold, italic, and bold italic. See the discussion of getFont() and decode() for more on font properties. Note that we haven't actually added a new font to the system we've only created a new name for an old font. With this line in the properties file, a Java program can use “AvantGarde” as a font name when this font is selected, AWT uses the font SansSerif for display. The ZapfDingbats font name has been dropped completely because the characters in this font have official Unicode mappings in the range \u2700 to \u27ff. Thus, TimesRoman is now Serif, Helvetica is now SansSerif, and Courier is Monospaced. The actual fonts available aren't changing the deprecated font names are being replaced by non-copyrighted equivalents.

For copyright reasons, the list is substantially different in Java 1.1: the available font names are TimesRoman, Serif, Helvetica, SansSerif, Courier, Monospaced, Dialog, and DialogInput. Under Java 1.0, on any platform, the available fonts were: TimesRoman, Helvetica, Courier, Dialog, DialogInput, and ZapfDingbats.

This method returns a String array of the fonts available. Each platform that supports Java provides a basic set of fonts to find the fonts supported on any platform, call Toolkit.getDefaultToolkit().getFontList(). Within AWT, a font is specified by its name, style, and point size. 3.1 FontsĪn instance of the Font class represents a specific font to the system. Finally, the SystemColor class (which is new to Java 1.1) provides access to the desktop color scheme. Next, the Color class is used to represent colors and can be used to specify the background color of any object, as well as the foreground color used to display a text string or a shape. The FontMetrics class gives you detailed information about a font, which you can use to position text strings intelligently. First, we discuss the Font class, which determines the font used to display text strings, whether they are drawn directly on the screen (with drawString()) or displayed within a component like a text field. The object workbench and integrated debugger facilitate a unique way for students to view objects created by their programs.This chapter introduces the java.awt classes that are used to work with different fonts and colors. These visualizations, which are particularly well suited for CS1 and CS2 students learning Java, include Control Structure Diagrams, UML Class Diagrams, and dynamic Object Views (including arrays, ArrayList, LinkedList, HashMap, and TreeMap). jGRASP is a freely available lightweight integrated development environment () that provides automatically generated visualizations for improving the comprehensibility of software. This includes the traditional CS1 (introduction to programming) and CS2 (introduction to data structures and algorithms). The purpose of the workshop is to introduce faculty to the advanced pedagogical features provided by jGRASP for teaching and learning Java, especially for first year students.
