Exemplo n.º 1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   JEditorPane editor = getEditor(e);
   if (editor != null) {
     StyledEditorKit kit = getStyledEditorKit(editor);
     MutableAttributeSet attr = kit.getInputAttributes();
     isUnderline = (StyleConstants.isUnderline(attr)) ? false : true;
     SimpleAttributeSet sas = new SimpleAttributeSet();
     StyleConstants.setUnderline(sas, isUnderline);
     setCharacterAttributes(editor, sas, false);
     boolean isEnabling = (StyleConstants.isBold(attr)) ? false : true;
     Integer position = getCursorPosition();
     if (editor != null
         && editor.getSelectedText() != null
         && editor.getSelectedText().length() > 0)
       controller.sendStyleChangeRequest(
           currentDocID,
           StyleChange.StyleType.UNDERLINE,
           isEnabling,
           position,
           editor.getSelectedText().length());
     updateDocToDataModel();
   }
 }
Exemplo n.º 2
0
 /**
  * Diese Methode prüft ob eine Stelle im Text unterstrichen ist
  *
  * @param pos (int) welche position soll abgefragt werden
  * @return (boolean) unterstrichen true / false
  */
 public boolean isUnderline(int pos) {
   Element element = getCharacterElement(pos);
   return StyleConstants.isUnderline(element.getAttributes());
 }