List of usage examples for javax.swing.text StyleConstants isBold
public static boolean isBold(AttributeSet a)
From source file:plugin.notes.gui.NotesView.java
/** * Updates Editing buttons based on the location of the cursor * *@param textPane text pane to update buttons base on *@param pos current text position *//*ww w . j a va2 s .com*/ private void updateButtons(JTextPane textPane, int pos) { StyledDocument doc = textPane.getStyledDocument(); AttributeSet set = doc.getCharacterElement(pos - 1).getAttributes(); AttributeSet set1 = doc.getCharacterElement(pos).getAttributes(); if (StyleConstants.isBold(set) && StyleConstants.isBold(set1)) { highlightButton(boldButton); } else { stdButton(boldButton); } if (StyleConstants.isItalic(set) && StyleConstants.isItalic(set1)) { highlightButton(italicButton); } else { stdButton(italicButton); } if (StyleConstants.isUnderline(set) && StyleConstants.isUnderline(set1)) { highlightButton(underlineButton); } else { stdButton(underlineButton); } int align = StyleConstants.getAlignment(set); stdButton(leftJustifyButton); stdButton(rightJustifyButton); stdButton(centerJustifyButton); if (align == StyleConstants.ALIGN_LEFT) { highlightButton(leftJustifyButton); } else if (align == StyleConstants.ALIGN_RIGHT) { highlightButton(rightJustifyButton); } else if (align == StyleConstants.ALIGN_CENTER) { highlightButton(centerJustifyButton); } int fontSize = StyleConstants.getFontSize(set); for (int i = 0; i < sizeCB.getItemCount(); i++) { String value = (String) sizeCB.getItemAt(i); if (value.equals(Integer.toString(fontSize))) { sizeCB.setSelectedItem(value); break; } } }