-
Book Overview & Buying
-
Table Of Contents
JavaFX 1.2 Application Development Cookbook
By :
In previous recipes (and chapters), we have seen the use of the Color class used to apply paint color to an object. In the recipe Applying cool paint effects with gradients, we explored how to use JavaFX's built-in gradient classes to apply paint effects to visual objects. But, what if you want to create your own customized paint? This is exactly what is covered in this recipe. You will learn how to create your own Paint instance, which can be used to fill in your objects.
This recipe makes use of the javafx.scene.paint.Paint class to create a customized Paint instance that can be used to paint any node object. We are also going to make use of additional classes, javax.imageio.ImageIO, java.net.URL, java.awt.geom.Rectangle2D, and java.awt.TexturePaint, that are used to load the image and create the paint texture.
Creating a customized paint involves extending class Paint. To illustrate how to accomplish this, the next code snippet...
Change the font size
Change margin width
Change background colour