JEditorPane i pogrubienie czcionki :/

0

Chcialbym sobie zrobic maly edytorek tekstu uzywajacy JEditorPane, no i wlasnie stanalem na przyciskach do pogrubiania, pochylania i podkreslania tekstu. Ktos moze mnie poratowac i napisac jak to sie robi? plizzzzzzzzzzzzzzzzzz :/

0

Mozna to wpisywac jako html metoda setText(String)

setText
public void setText(String t)Sets the text of this TextComponent to the specified content, which is expected to be in the format of the content type of this editor. For example, if the type is set to text/html the string should be specified in terms of HTML.
This is implemented to remove the contents of the current document, and replace them by parsing the given string using the current EditorKit. This gives the semantics of the superclass by not changing out the model, while supporting the content type currently set on this component. The assumption is that the previous content is relatively small, and that the previous content doesn't have side effects. Both of those assumptions can be violated and cause undesirable results. To avoid this, create a new document, getEditorKit().createDefaultDocument(), and replace the existing Document with the new one. You are then assured the previous Document won't have any lingering state.

Leaving the existing model in place means that the old view will be torn down, and a new view created, where replacing the document would avoid the tear down of the old view.
Some formats (such as HTML) can install things into the document that can influence future contents. HTML can have style information embedded that would influence the next content installed unexpectedly.
An alternative way to load this component with a string would be to create a StringReader and call the read method. In this case the model would be replaced after it was initialized with the contents of the string.

cos wiecej na ten temat:
http://java.sun.com/j2se/1.5.0/docs/api/

0

Dzięki, nie myślałem że to tak się robi. Zapomniałem napisać że chciałbym edytować dokumenty formacie text/rtf, ktoś wie jaki znacznik rtf pogrubia tekst :]

1 użytkowników online, w tym zalogowanych: 0, gości: 1