| shapesoverview |
JTextComponent objects provide
built-in support for hit testing and displaying international text.
If you just want to draw a static text string, you can render it
directly through Graphics2D by using the
drawString method. To specify the font, you use the
Graphics2D setFont method.
If you want to implement your own text-editing routines or need more
control over the layout of the text than the text components provide,
you can use the Java 2D text layout classes in java.awt.font.
A font can be thought of as a collection of glyphs. A single font might have many faces, such as heavy, medium, oblique, gothic, and regular. All of the faces in a font have similar typographic features and can be recognized as members of the same family. In other words, a collection of glyphs with a particular style form a font face; a collection of font faces forms a font family; and the collection of font families forms the set fonts available on the system.
When you're using the Java 2D API, you specify fonts by using an
instance of Font. You can determine what fonts are
available by calling the static method
GraphicsEnvironment.getLocalGraphicsEnvironment and then
querying the returned GraphicsEnvironment. The
getAllFonts method returns an array that contains
Font instances for all of the fonts available on the
system; getAvailableFontFamilyNames returns a list of the
available font families.
The GraphicsEnvironment also describes the collection of platform rendering devices, such as screens and printers, that a Java program can use. This information is used when the system performs the conversion from user space to device space during rendering.
Graphics2D
also supports the specification
of fonts by logical name. To get a list of the logical font names, call
java.awt.Toolkit.getFontList.
JLabel or
JTextComponent manage text layout for you.
JTextComponent supports bidirectional text and is
designed to handle the needs of most international applications. For
more information about using Swing text components, see
Using Text ComponentstutorialIcon (in the 2D Graphics trail)
If you are not using a Swing text component to automatically display text, you can use one of two Java 2D mechanisms for managing text layout.
TextLayout class to manage text layout,
highlighting, and hit detection. The facilities provided by
TextLayout handle most common cases, including strings
with mixed fonts, mixed languages, and bidirectional text. For more
information about TextLayout, see
Managing Text LayoutotherIcon (outside of the tutorial) in the Java 2D Programmer's Guide.
GlyphVector objects by using
Font and then render each GlyphVector through
Graphics2D. For more information about implementing your
own text layout mechanisms,
Implementing a Custom Text Layout MechanismotherIcon (outside of the tutorial) in the Java 2D Programmer's Guide.
| shapesoverview |
Bhopal news
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100