944,208 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3822
  • Java RSS
Jan 1st, 2005
0

setting font of selected text

Expand Post »
I know how to se the font of a regular JTextArea, but how would I get an reference to the selected text and only select that?

Here is what I have so far:
Java Syntax (Toggle Plain Text)
  1. setFont(new Font(font, style = Font.BOLD, size));
this works but changes whole area

Java Syntax (Toggle Plain Text)
  1. textArea2.getSelectedText().setFont(new Font("sansserif",Font.BOLD, 12));

this doesn't work, and this is what I need..

How can i do this/
Similar Threads
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jan 1st, 2005
0

Re: setting font of selected text

I just read that you can't do this in a JTextArea. Im gonna have to convert to JTextPane.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Aug 12th, 2010
-1
Re: setting font of selected text
it so easy like walking....
Reputation Points: 8
Solved Threads: 0
Newbie Poster
shielaborja is offline Offline
2 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: problem in writing to a file
Next Thread in Java Forum Timeline: Setting up log4j





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC