954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

setting font of selected text

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:

setFont(new Font(font, style = Font.BOLD, size));

this works but changes whole area

textArea2.getSelectedText().setFont(new Font("sansserif",Font.BOLD, 12));


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

How can i do this/

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

I just read that you can't do this in a JTextArea. Im gonna have to convert to JTextPane.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

it so easy like walking....

shielaborja
Newbie Poster
2 posts since Aug 2010
Reputation Points: 8
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You