JGRASP COLOR THEMES HOW TO
Font propertiesĮarlier, you saw how to use system properties to add aliases for fonts. The isItalic() method returns true if the current font is either italic or bold and italic. The isBold() method returns true if the current font is either bold or bold and italic. The isPlain() method returns true if the current font is neither bold nor italic.
JGRASP COLOR THEMES WINDOWS
For example, on a Windows 95 platform, this would be an instance of. The object FontPeer is a platform-specific subclass of. The getPeer() method retrieves the platform-specific peer object. The actual displayed size may be different. The getSize() method retrieves the point size of the font, as set by the size parameter in the constructor. getStyle() is more useful if you want to copy the style of some font when creating another. It is easier to use the isPlain(), isBold(), and isItalic() methods to find out the current style. Compare this value with the constants Font.BOLD, Font.PLAIN, and Font.ITALIC to see which style is meant. The getStyle() method returns the current style of the font as an integer. If nobody set the property, both methods return AvantGarde, and the system uses the default font (since AvantGarde is a nonstandard font). For example, if the constructor was new Font (" AvantGarde", Font.PLAIN, 10) and the =Helvetica property is set, then getName() returns AvantGarde, and getFamily() returns Helvetica. If the font has been aliased to another font, the getFamily() method returns the name of the platform-specific font, not the alias. The getFamily() method returns the actual name of the font that is being used to display characters. Remember that system properties can be used to alias font names, so the name used in the constructor isn't necessarily the actual name of a font on the system. This is the name passed to the constructor for the specific instance of the Font. The getName() method returns the font's logical name.
![jgrasp color themes jgrasp color themes](https://docs.oracle.com/javase/tutorial/figures/uiswing/components/ColorChooserDemoMetal.png)
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.
![jgrasp color themes jgrasp color themes](https://packagecontrol.io/readmes/img/737e7f4799587639c87cba8541455664b103de4d.png)
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.
![jgrasp color themes jgrasp color themes](https://i.pinimg.com/originals/8f/28/92/8f28921b422d8dfa8ae60ec8a680aaeb.jpg)
This chapter introduces the java.awt classes that are used to work with different fonts and colors.