Java Reference
In-Depth Information
Embolden your font
In its declarative form, Font{name:"Arial Black" size:12} , you have to depend on
the name of the font to indicate the font's weight. However, you have the option of using
Font.font(name:String, weight:FontWeight, size:Number) function to create
an instance of the font where the font-weight can be specified as follows:
Text {
x:50 y: 25
font: Font.font ("Arial", FontWeight.BOLD , 28)
content: "This is a simple text demo."
Using the function to create the font, you are able to specify the font's name, the font's weight,
and the size of the font in point. The FontWeight class is used to indicate the boldness of
the type used to render the font.
Locating fonts
JavaFX is capable of using True Type fonts embedded in the JavaFX application or hosted
on the target device. The JavaFX runtime will try to first find fonts by searching in the
application's embedded fonts, followed by a search in the JavaFX's installed fonts, and then
a final searching within the device-installed fonts. If the font is still not found, JavaFX will default
to the runtime's default font. You can query fonts that are available for use in JavaFX using
the following methods:
F Font.getFontNames():String[] —returns all fonts reachable by the
JavaFX runtime.
F Font.getFontNames(familyName:String):Object[] —returns fonts that
share the specified family name.
See also
F Drawing simple shapes
Handling user input
As a platform designed to build rich user interface applications, JavaFX provides many
ways for users to interact with your applications. In order to implement user interactions
in your applications, at a minimum, you will have to capture key presses on the keyboard
and gestures from pointing devices. This recipe shows you how to capture keyboard and
mouse events.
Search WWH ::

Custom Search