Set JTextArea text font

Source code below will show you, how to set JTextArea text font.

*****************************************************************************
COMPLETE SOURCE CODE FOR : SetJTextAreaTextFont.java
*****************************************************************************


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextFont
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Tahoma
//Font Style : Default text area font style
//Font Size : Default text area font size
Font newTextAreaFont=new Font("Tahoma",textArea.getFont().getStyle(),textArea.getFont().getSize());

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

//Create a window using JFrame with title ( Set JTextArea text font )
JFrame frame=new JFrame("Set JTextArea text font");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


*****************************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************************

RELAXING NATURE VIDEO