• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set TextArea to bold using default font?  RSS feed

 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
does anyone here know how to get the font that is used as default. I have a TextArea in my application and want to set the text to bold without changing the rest of the font?
Thanks for the help!!
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a simple example that might help ...

This looks at the font in the text area and derives a new font that is bolded. If the font is already bold, it won't change it. You could easily adapt this to turn bold on and off if you needed to.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the "JTextArea", you aren't restricted to a single font for the entire text. You can change any of the font characteristics (color, bold, italics, different font, etc.) in any part of the document.
A good place to start is Sun'sText Component Features tutorial.
I realize that this may be much more than what you're trying to accomplish, but it allows you to have complete control over how text is displayed. I used it to write an SQL query editor, displaying keywords in blue, comments, in green, etc. It's cool stuff.
 
Theo van Loon
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot it's exactly what i needed!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!