436
|
Chapter 11, Native Integration and Packaging
#86 Make Quick Look and Feel Changes
HACK
Text Components
Text components have font settings in addition to their colors. This lets you
set a component to use a different font style or size. You can even load a cus-
tom font from a file:
Font font = Font.createFont(Font.TRUETYPE_FONT,
new FileInputStream("dungeon.ttf"));
font = font.deriveFont(Font.BOLD,16f);
UIManager.put("Label.font",font);
This would look like Figure 11-12.
Most components also have margins that are defined by an
Insets object. A
text field with large insets:
UIManager.put("TextField.margin", new Insets(25,25,25,25));
would look like Figure 11-13.
Figure 11-11. A sample program with green components
Figure 11-12. A custom font

Get Swing Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.