font - Set Font and Color to Text of JTextArea Component in Java GUI - Free Source Code

Set Font and Color to Text of JTextArea Component in Java GUI – Free Source Code

Posted on

font - Set Font and Color to Text of JTextArea Component in Java GUI - Free Source Code

This can be a continuation of my different tutorial entitled JTextArea Component in Java GUI. This tutorial will educate you set/choose font and shade for the JTextArea or JTextField element.

1. Initially, Open JCreator or NetBeans and make a java program with a file title of jTextArea.java. Once you click on the hyperlink above, copy first all of the code there.

2. Now, insert this code after the JScrollPane scrollingArea = new JScrollPane(txtArea);. This code will add font and shade to the textual content of JTextArea Part.

We have now instantiated the Font class to get the font type, dimension, and kind. Right here, we used the Font “Arial” that’s within the double quote, ITALIC because the font type, and 12 as the dimensions of our font. After instantiating, the txtArea variable for JTextArea element makes use of the setFont technique that has the parameter of the font variable that we’ve got created. This may set off to set the font for the JTextArea. We additionally used the setForeground technique with a Coloration.RED within the parameter to make the textual content within the JTextArea to be in shade Pink. Make it possible for after the Coloration class, capitalization is required for the colour.

Hope this hepls! 🙂

Finest Regards,

Engr. Lyndon R. Bermoy
IT Teacher/System Developer/Android Developer
Cell: 09079373999
Phone: 826-9296
E-mail:[email protected]

Go to and like my web page on Fb at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: Ser Bermz