Reputation:

Changing the font of text being typed in a JTextArea

I am working on a chat application and I want the user to be able to change their font while typing messages.

I tried using the setFont() method but it changes the font for the entire text within the JTextArea component and when the text is sent to the display area, another JTextArea component, the font changes do not appear. Instead it displays the text in the font of that set in the display area.

What I want to do is to change the font for either highlighted textarea or for the marker only and when the text is sent to the display area, the font changes should be evident.

Upvotes: 2

Views: 1152

Answers (1)

evilReiko
evilReiko

Reputation: 20473

JTextArea supports simple plain text with simple styling only.

I'm having same problem, but seems the answer is that you should use JEditorPane or JTextPane instead of JTextArea.

Editor Panes and Text Panes

Upvotes: 2

Related Questions