I am looking for the most simple way to control JTextPane (its inner text) font color and font size within selected text only.
I know I must look at StyledDocument but its snippets show the JMenu action listener tricks but not JButton 🙁
I couldn’t find code snippets which could show how to change selected text style by JButton clicked (the actionPerformed(…) method) etc 🙁
I mean something in this direction
- A) I have a text in JTextPane lets say “My home is to turn into
borabora and this is…” - B) Text “borabora” is selected in JTextPane
- C) JButton(“size=16”) was clicked
- D) Text “borabora” size becomes 16
I couldn’t find this kind of snippets so I need your advice.
Any useful comment is appreciated
In your actionPerformed method of the applicable jbutton you could run this. (modify as needed.)