2

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.

4

1 回答 1

2

JTextArea 仅支持具有简单样式的简单纯文本。

我有同样的问题,但似乎答案是你应该使用 JEditorPane 或 JTextPane 而不是 JTextArea。

编辑器窗格和文本窗格

于 2009-12-19T10:50:59.987 回答