Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changin font in a JTextArea

 
Richard Robbins
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setFont() method.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
Look at javax.swing.text.Document and its children.
Regards,
Manfred.
 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic