File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Changin font in a JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changin font in a JTextArea" Watch "Changin font in a JTextArea" New topic

Changin font in a JTextArea

Richard Robbins
Ranch Hand

Joined: Mar 07, 2001
Posts: 66
I am writing a Swing application in which input into a JText Area can be done in two ways: typing the text in directly, and pressing a button. I want the font of the text entered when using the button to be different from the font used when typing the text in directly. How do I do this?

Richard Robbins is one of the founders of, a resource for free website templates and Photoshop tutorials. He also consults for an online boutique selling baptism dresses and christening gowns.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
setFont() method.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Richard,
Look at javax.swing.text.Document and its children.
Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
I dont think JTextArea will help u. Though u can change the font using setFont(), but u can't have a JTextArea with text in different fonts. Better use JTextPane. JTextPane supports different fonts and colors too.
I agree. Here's the link:
subject: Changin font in a JTextArea
It's not a secret anymore!