1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
this.document=textPaneTexte.getStyledDocument();
String textSelect = textPaneTexte.getSelectedText();
int position = this.textPaneTexte.getCaretPosition();
this.style=this.document.getLogicalStyle(textPaneTexte.getCaretPosition());
this.attributes = new SimpleAttributeSet(this.textPaneTexte.getCharacterAttributes());
System.out.println("avant update");
for (Enumeration en = this.attributes.getAttributeNames(); en.hasMoreElements() ;) {
System.out.println(en.nextElement());
}
if(e.getSource() == this.buttonTextBold) {
if(StyleConstants.isBold(this.attributes))
this.attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.FALSE);
else
this.attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
}
else if(e.getSource() == this.buttonTextItalic) {
if(StyleConstants.isItalic(this.attributes))
this.attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.FALSE);
else
this.attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
}
else if(e.getSource() == this.buttonTextUnderline) {
if(StyleConstants.isUnderline(this.attributes))
this.attributes.addAttribute(StyleConstants.CharacterConstants.Underline, Boolean.FALSE);
else
this.attributes.addAttribute(StyleConstants.CharacterConstants.Underline, Boolean.TRUE);
}
else if(e.getSource() == this.comboBoxPolice) {
StyleConstants.setFontFamily(this.style, (String)this.comboBoxPolice.getSelectedItem());
}
else if(e.getSource() == this.comboBoxTailleTexte) {
StyleConstants.setFontSize(this.style, Integer.parseInt((String)this.comboBoxTailleTexte.getSelectedItem()));
}
this.textTampon = textSelect;
this.previousPosition = position;
this.textPaneTexte.setCharacterAttributes(attributes, true);
System.out.println("fin\napres update:");
for (Enumeration en = this.attributes.getAttributeNames(); en.hasMoreElements() ;) {
System.out.println(en.nextElement());
} |
Partager