In this section, you will see how to change chunk color in java.
changing Chunk Color
In this program we are going to tell you how you can
change the color of chunk color .This example tell you how you can change
the color of chunk and how you can add fonts and gives the size of the
fonts.
Code Description:
In this Example we create the object of the paragraph .In this paragraph we add the chunk and set the font by using the getFont(fontname,size,coloor ).The getFont() method is a method of FontFactory. We are changing the color of the chunk by passing the color values into the getFont() method.
FontFactory:
The class
FontFactory is used to create a Font. It is easiest way to get a new Font
object. FontFactory has an API with methods that can construct a Font object
of any kind. The constructed font is in a uniform way. There are some CID
fonts which are not in it.
getFont:
The getFont() method is used to gets the
current font for the window.The getFont method is used to get Font-Object
from FontFactory class.
Font.DEFAULTSIZE:
This is used to set the default size.
Color(0xFF, 0x00, 0x00):
This constructor
is used to create the object of the color. We pass three hexadecimal values
to which gives the combination of colors.
Font.BOLD:
This is used to set text
BOLD.
Font.ITALIC:
This is used to set
text ITALIC.
FontFactory.HELVETICA:
This is used to set text style
HELVETICA.
The code of the program is given below:
import java.awt.Color;
|
The output of the program is given below: