|
|
|
@ -256,8 +256,11 @@ public class RichTextToolBar extends BasicPane{
|
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
boolean isSub = RichTextToolBar.this.subPane.isSelected(); |
|
|
|
|
// 调用setCharacterAttributes函数设置文本区选择文本的字体
|
|
|
|
|
MutableAttributeSet attr = new SimpleAttributeSet(); |
|
|
|
|
if (!isSub && RichTextToolBar.this.superPane.isSelected()) { |
|
|
|
|
StyleConstants.setSuperscript(attr, false); |
|
|
|
|
} |
|
|
|
|
// 调用setCharacterAttributes函数设置文本区选择文本的字体
|
|
|
|
|
StyleConstants.setSubscript(attr, !isSub); |
|
|
|
|
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); |
|
|
|
|
} |
|
|
|
@ -269,6 +272,9 @@ public class RichTextToolBar extends BasicPane{
|
|
|
|
|
boolean isSuper = RichTextToolBar.this.superPane.isSelected(); |
|
|
|
|
// 调用setCharacterAttributes函数设置文本区选择文本的字体
|
|
|
|
|
MutableAttributeSet attr = new SimpleAttributeSet(); |
|
|
|
|
if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { |
|
|
|
|
StyleConstants.setSubscript(attr, false); |
|
|
|
|
} |
|
|
|
|
StyleConstants.setSuperscript(attr, !isSuper); |
|
|
|
|
setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); |
|
|
|
|
} |
|
|
|
|