lynux100
Estou fazendo assim:
public class MensagemGui extends javax.swing.JFrame {
private BoldAction negritoAction;
public MensagemGui() {
negritoAction = new BoldAction();
JButton negritoJButton = new JButton(negritoAction);
}
}
public class BoldAction extends StyleEditorKit.StyledTextAction {
public BoldAction() {
super("");
}
public void actionPerformed(ActionEvent e) {
JEditorPane editor = getEditor(e);
if(editor != null) {
StyledEditorKit kit = getStyledEditorKit(editor);
MutableAttributeSet attr = kit.getInputAttributes();
boolean bold = (StyleConstants.isBold(attr)) ? false : true;
SimpleAttributeSet sas = new SimpleAttibuteSet();
StyleConstants.setBold(sas, bold);
setCharacterAttributes(editor, sas, true);
}
}
}
lynux100