Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'introduction to java: 3- fonts and colors', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 3 In this chapter Fonts FontMetrics Color SystemColor Displaying Colors Using Desktop Colors Fonts and Colors This chapter introduces the java.awt classes that are used to work with different fonts and colors. First we discuss the Font class which determines the font used to display text strings whether they are drawn directly on the screen with draw-String or displayed within a component like a text field. The FontMetrics class gives you detailed information about a font which you can use to position text strings intelligently. 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. Finally the SystemColor class which is new to Java 1.1 provides access to the desktop color scheme. 3.1 Fonts An instance of the Font class represents a specific font to the system. Within AWT a font is specified by its name style and point size. Each platform that supports Java provides a basic set of fonts to find the fonts supported on any platform call Toolkit.getDefaultToolkit .getFontList . This method returns a String array of the fonts available. Under Java 1.0 on any platform the available fonts were TimesRoman Helvetica Courier Dialog Dialoginput and ZapfDingbats. 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. The actual fonts available aren t changing the deprecated font names are being replaced by non-copyrighted equivalents. Thus TimesRoman is now Serif Helvetica is now SansSerif and Courier is Monospaced. The ZapfDingbats font name has been dropped completely because the characters in this font have official Unicode mappings in the range u2700 to u27ff. 66 3.1 Fonts 67 NOTE If you desire non-Latin font support with Java 1.1 use the Unicode mappings for the characters. The actual font used is specified in a set of .