GeeCON Prague 2014*
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


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changin font in a JTextArea" Watch "Changin font in a JTextArea" New topic
Author

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 WebsiteTemplateDatabase.com, 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.
Regards,
Manfred.
Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
Hi,
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.
..regards
...saj
 
GeeCON Prague 2014
 
subject: Changin font in a JTextArea