
Build a Colorful Vector-Based Button #62
Chapter 8, Rendering
|
309
HACK
Script font at http://www.free-fonts.com/. Once you have a .ttf file, run the
demo like this:
cadamson% java FontLoadingDemo marriage_script.ttf
Running the demo pops up a window like the one seen in Figure 8-6.
With this technique, and a consistent scheme for bundling your application
resources (i.e., stuffing all your fonts in a JAR file, perhaps with other
resources like images, sounds, and localizations), you have the freedom to
use whatever fonts you like in your GUI, without worrying about what end
users do or don’t have installed.
H A C K
#62
Build a Colorful Vector-Based Button Hack #62
Build a resolution-independent OS X-style button using scalable graphics
code.
The button in this hack is resolution independent, meaning that it can resize
and rescale automatically as the user’s windows and display change, stretch-
ing and tiling the graphics to fill the new space. The button doesn’t depend
on being any particular size to look good. As higher-quality and higher-
resolution monitors become more common, users will start to expect attrac-
tive interfaces that scale and reflow with their increasingly expansive dis-
plays. This hack shows how to create an attractive
JButton that will scale
with both size and resolution, opening the door for a completely vector-
drawn Swing Look and Feel.
Use Scaling to Your Advantage
Since this