In most cases, you can still use the getDescent() method; visually, it is okay for an occasional character to extend into the space between lines. When to Use Java Enum? And in same way go to “foreground” option and choose font color whatever you want just describe and mention in bellow image. Returns the inner shadow color of the bevel border When a menu is selected, the textHighlightText color is normally the text color. specified area of the destination drawable surface. AWT's Color class lets you define and work with Color objects. It requires a name, style, and size. The program will use its default colors for inactive components and highlighted text. public final static SystemColor inactiveCaptionText. Sets the foreground color of this object. Fetches the background color to use to render the glyphs. Returns the inner highlight color of the bevel border The hashCode() method returns a hash code for the font. If called with name set to myPackage.myClass.inputFont, getFont() returns a 12-point, plain Helvetica Font object. Since the class is abstract, you cannot create a FontMetrics object. The isBold() method returns true if the current font is either bold or bold and italic. The only objects in this class are the twenty or so SystemColor constants. The offset specifies the element of data to start with; length specifies the number of elements to use. Returns the color for the specified state. Sets the paint mode of this graphics context to alternate between Sets the foreground color for selected cells. The format of name is the same as that used by getColor(). You can use the results to position objects around text or to provide special effects like shadows and underlining. As an example, pure red will have an R value of 1.0, a G value of 0.0, and a B value of 0.0. The addNotify() method sizes the frame appropriately. The bytesWidth() method allows you to calculate the advance width of the byte array data, without first converting data to a String and calling the stringWidth() method. It is easier to use the isPlain(), isBold(), and isItalic() methods to find out the current style. long: outlineColor(java.awt.Color outlineColor) Sets the turtle's outlineColor color. Example 3-1 and Figure 3-2 show an example that centers several text strings (taken from the command-line arguments) in a Frame. The toString() method of Font returns a string showing the current family, name, style, and size settings. Most browsers do not permit modifying properties, so there is no file. Leading is the amount of space required between lines of the same font. If the property value does not convert to an integer, defaultColor is returned. Color. Normally, the file goes into a subdirectory of the installation directory, or for environments where users have home directories, in a subdirectory for the user. Many other color constants are defined in the SystemColor class. The getHSBColor() method creates a Color object by using hue, saturation, and brightness instead of red, green, and blue values. The getBlue() method retrieves the current setting for the blue component of the color. Provides user interface objects built according to the Depending on which constructor you use, you can specify the components as integers between 0 and 255 (most intense) or as floating point intensities between 0.0 and 1.0 (most intense). The getRed() method retrieves the current setting for the red component of the color. Bool is the set { True, False } 2. If you're not using the JDK, the class names may be different, but the principle still applies: you don't have to worry about the concrete class. Thus, TimesRoman is now Serif, Helvetica is now SansSerif, and Courier is Monospaced. A font's size is represented as an integer. The isPlain() method returns true if the current font is neither bold nor italic. Ordinarily, when not depressed, the controlDkShadow should be used for the object's bottom and right edges. static Color BLACK -- The color black. This chapter introduces the java.awt classes that are used to work with different fonts and colors. The charsWidth() method allows you to calculate the advance width of the char array data, without first converting data to a String and calling the stringWidth() method. Four variables describe the height of a font: leading (pronounced like the metal), ascent, descent, and height. In both the parameter and the return value, the three components are placed in the array as follows: public static Color getHSBColor (float hue, float saturation, float brightness). Sets the background color of this component. When you press a key, they appear darker. If you want underlining, you have to do it manually, with the help of FontMetrics. Provides user interface objects built according to Table 3–1: Comparison of RGB and HSB Colors. Creates a line border with the specified color, thickness, Java Swing Tutorial - Java Swing Colors « Previous; Next » An object of the java.awt.Color class represents a color. 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. For example, putting the line below in the properties file or a resource file (resource files are new to Java 1.1) defines the name “AvantGarde” as an alias for the font SansSerif: 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. Although these constants are public static final, they actually have a very strange behavior. When we discuss the Component class (see Chapter 5, Components), you will see how to use these color objects, and our discussion of the SystemColor subclass (new to Java 1.1; discussed later in this chapter) shows you how to control the colors that are painted on the screen. The brighter() method creates a new Color that is somewhat brighter than the current color. Sets the Color used to flash drawing operations. Creates a color with the specified RGB value, where the red component is in bits 16-23 of the argument, the green component is in bits 8-15 of the argument, and the blue component is in bits 0-7. public static Color getColor (String name, int defaultColor). The window color represents the background color of the window's display area. Returns the background color to be used for non selected nodes. The getName() method returns the font's logical name. * Section 3.6 contains a usage example. The windowText color represents the color of the text drawn within the window. Basic look and feel. Rob Spoor wrote:Your class is missing the following three methods: The first two are required as per the contract of java.util.Map. Earlier, you saw how to use system properties to add aliases for fonts.