Search code examples
clojureseesaw

Different colors/fonts in one text area


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

I want to add something like "hh:mm:ss Nickname: message", with time being gray, name - blue, message - black.


Solution

  • I made a mistake in my comment: it is JTextPane what you want, not JTextArea.

    It turns out that seesaw supports JTextPane. See (seesaw.core/styled-text), which creates JTextPanes, and (seesaw.core/style-text!) which applies different styles to the text inside the pane.
    Their usage seems to be pretty straightforward: first you define mapping id -> style during pane construction, and then you use this id when you assign styles to parts of the text.