-1
最近、スタイル定数、スタイル付きドキュメント、テキストペインを使用しています。ユーザーのハイライト/ただ、「Hello World」の中に「Oのワール」を選択した場合、私は、一例としてスタイル付きドキュメント/テキストペインからフォント文字と色を取得
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.
以下のコードでそれを示す選択あなたが/ハイライトテキストの一部を編集することができます知っています"o worl"は黒色に変更され、フォントレターはArialになります。
私の質問は、どのように高級/選択されたテキストからフォント文字と色を得ることができるかということです。私はそれを別々の変数に保存する方法を知りたい(1つはカラー用、もう1つはフォントレター用)。