Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Program to get JTextArea font information
Let’s say the following is our JTextArea −
JTextArea textArea = new JTextArea("This is demo text.");
Now, get the font using the Font class getFont() method as shown below −
Font font = textArea.getFont();
System.out.println("Font = "+font);
The following is an example to get JTextArea font information in Java −
Example
package my;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.*;
public class SwingDemo {
SwingDemo(){
JFrame frame = new JFrame();
JTextArea textArea = new JTextArea("This is demo text.");
Font font = textArea.getFont();
System.out.println("Font = "+font);
frame.add(textArea);
frame.setSize(550,300);
frame.setLayout(new GridLayout(2, 2));
frame.setVisible(true);
}
public static void main(String args[]) {
new SwingDemo ();
}
}
Output

The Font info is displayed in Console −

Advertisements
