Different colors / fonts in one text area

Can I have different foreground colors in the same text area? Different fonts?

I want to add something like "hh: mm: ss Nickname: message", eventually gray, name is blue, message is black.

+3
clojure seesaw


source to share


2 answers


I made a mistake in my comment: this is the JTextPane that you want, not the JTextArea.



It turns out that the swing supports JTextPane. See (seesaw.core/styled-text)

which creates JTextPane

s and (seesaw.core/style-text!)

which applies different styles to the text inside the panel.
Using them seems pretty straightforward: first you define the display id -> style

when you build the panel, and then you use that id

when you style a piece of text.

+3


source to share


Textarea is a standard HTML element and cannot accept more styles. One way to achieve this is to use an iFrame and style the content inside the iFrame. Otherwise, to achieve without iFrame, choose an editor that supports these features. One of such editors is WMD, which is used on stackoverflow. WMD files here



0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics