Lately I have been using Style Constants, Styled Documents and Text Pane. I know that you can edit a part of the text that you highlight/select showing it in the code below
StyledDocument doc = this.tpText.getStyledDocument();
Style style = this.tpText.addStyle("stylish", null);
StyleConstants.setForeground(style, color.BLACK);
StyleConstants.setFontFamily(style, "Arial");
doc.setCharacterAttributes(this.tpText.getSelectionStart(), this.tpText.getSelectionEnd() - this.tpText.getSelectionStart(), this.tpText.getStyle("stylish"), true);//This is the piece of code (last line) that will set all the attributes to the highlited text.
As an example, if the user highlights/selects "o worl" in "hello world", just the "o worl" will be changed to color black and the font letter will be Arial.
Now, my question is: how can you get the font letter and color from a highlihted/selected text? I want to know how can I save that in seperate variables (one for color and the other for the font letter).