participate


Swing - Change the font of part of a JTextArea
This question is not answered.

<<   Back to Forum  |   Give us Feedback
This topic has 3 replies on 1 page.
francois203
Posts:33
Registered: 9/22/09
Change the font of part of a JTextArea   
Nov 7, 2009 4:21 PM
 
 
Hi,
I would like to know if it is possible to change the font of part of a JTextArea, because the setFont method changes the entire text.
 
Encephalopathic
Posts:13,714
Registered: 12/20/07
Re: Change the font of part of a JTextArea   
Nov 7, 2009 4:26 PM (reply 1 of 3)  (In reply to original post )
 
 
As per the Sun text component tutorial:

JTextArea can display multiple lines of editable text. Although a text area can display text in any font, all of the text is in the same font. Use a text area to allow the user to enter unformatted text of any length or to display unformatted help information.

To achieve your goal, you may need to look into using another text component such as a JEditorPane or JTextPane. I recommend that you have a look at the tutorial linked above.
 
francois203
Posts:33
Registered: 9/22/09
Re: Change the font of part of a JTextArea   
Nov 7, 2009 4:35 PM (reply 2 of 3)  (In reply to #1 )
 
 
Thanks.
 
Encephalopathic
Posts:13,714
Registered: 12/20/07
Re: Change the font of part of a JTextArea   
Nov 7, 2009 4:55 PM (reply 3 of 3)  (In reply to #2 )
 
 
Welcome and good luck!
 
This topic has 3 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 54
  • Guests : 135

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums