Java 类javax.swing.text.StyledEditorKit 实例源码

项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */

    // Function to bold when button is clicked
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */

    // Function to italicize when button is clicked
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    // Function to underline when button is clicked
    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:PasswordSafe    文件:CEditorBoldAction.java   
public void action()
{
    // FIX bold word if no selection! (only if chars on both sides are letters or digits)
    // nn|nn      ->  BB|BB
    // nn|.       ->  nn|.
    // <sp>|<sp>  ->  <sp>|<sp>
    // BBB|nnn    ->  nnn|nnn
    JEditorPane ed = getEditor();
    if(ed != null)
    {
        StyledEditorKit k = getStyledEditorKit(ed);
        if(k != null)
        {
            MutableAttributeSet as = k.getInputAttributes();

            boolean on = StyleConstants.isBold(as);

            SimpleAttributeSet newAttrs = new SimpleAttributeSet();
            StyleConstants.setBold(newAttrs, !on);
            setCharacterAttributes(ed, newAttrs, false);
        }
    }
}
项目:PasswordSafe    文件:InfoField.java   
public void setText(String text)
{
    if(CKit.startsWithIgnoreCase(text, "<html>"))
    {
        setEditorKit(new CHtmlEditorKit());
        setFont(getFont());
        setForeground(getForeground());
    }
    else
    {
        setEditorKit(new StyledEditorKit());
    }

    super.setText(text);
    setCaretPosition(0);
}
项目:wikit    文件:About.java   
public static JPanel createPanel() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    JTextPane editorPane = new JTextPane();
    editorPane.setEditable(false); 
    //wrap long line
    editorPane.setEditorKit(new StyledEditorKit());
    editorPane.setContentType("text/html");     
    try {
        URLClassLoader urlLoader = (URLClassLoader)About.class.getClassLoader();
        String html = About.class.getPackage().getName().replaceAll("\\.", "/") + "/about.html";
        System.out.println(html);
        URL url = urlLoader.findResource(html);//可以用html格式文件做你的帮助系统了
    editorPane.setPage(url);
   } catch (IOException e1) {
    editorPane.setText(e1.getMessage());
   } 
    //editorPane.setText("<html><body>个人主页:<a href='xiatian.irm.cn'>http://xiatian.irm.cn/</a></body></html>");


    mainPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);
    return mainPanel;
}
项目:CodenameOne    文件:HTMLEditor.java   
/** Creates new form HTMLEditor */
public HTMLEditor(EditableResources res, String htmlText) {
    initComponents();
    this.res = res;
    htmlComponent = new com.codename1.ui.html.HTMLComponent();
    htmlComponent.setBodyText(htmlText, "UTF-8");
    final CodenameOneComponentWrapper wrapper = new CodenameOneComponentWrapper(htmlComponent);
    uiPreview.add(java.awt.BorderLayout.CENTER, wrapper);
    wysiwyg.setText(htmlText);
    source.setText(htmlText);
    Listener l = new Listener();
    wysiwyg.getDocument().addDocumentListener(l);
    source.getDocument().addDocumentListener(l);
    JButton b = jToolBar1.add(new StyledEditorKit.BoldAction());
    b.setText("<html><body><b>B</b></body></html>");
    JButton i = jToolBar1.add(new StyledEditorKit.ItalicAction());
    i.setText("<html><body><i>I</i></body></html>");
    JButton u = jToolBar1.add(new StyledEditorKit.UnderlineAction());
    u.setText("<html><body><u>U</u></body></html>");
    jToolBar1.add(new InsertImageAction());
}
项目:cn1    文件:JEditorPane.java   
@Override
public synchronized void replaceSelection(final String s) {
    if (!isEditable()) {
        new DefaultEditorKit.BeepAction().actionPerformed(null);
        return;
    }
    int start = getSelectionStart();
    int end = getSelectionEnd();
    Document doc = getDocument();
    try {
        if (start != end) {
            doc.remove(start, end - start);
        }
        //May be these attributes placed in Document ????
        AttributeSet as = (editorKit instanceof StyledEditorKit) ? ((StyledEditorKit) editorKit)
                .getInputAttributes()
                : null;
        if (s != null) {
            doc.insertString(start, s, as);
        }
    } catch (BadLocationException e) {
    }
}
项目:cn1    文件:HTMLEditorKitTest.java   
public void testGetActions() throws Exception {
    Action[] ancestorActions = new StyledEditorKit().getActions();
    Action[] actions = editorKit.getActions();
    assertEquals(12, actions.length - ancestorActions.length);

    Action[] predefinedInsertHTMLTextActions = createPredefinedInsertHTMLTextActions();
    for (int i = 0; i < predefinedInsertHTMLTextActions.length; i++) {
        Action action = findActionWithName(actions,
            predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        if (action != null) {
            assertTrue("Action is not same" + action.getValue(Action.NAME),
                       compareInsertHTMLTextActions(action,
                                                    predefinedInsertHTMLTextActions[i]));
        } else {
            fail("Action not found: " + predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        }
    }
}
项目:cn1    文件:HTMLEditor.java   
/** Creates new form HTMLEditor */
public HTMLEditor(EditableResources res, String htmlText) {
    initComponents();
    this.res = res;
    htmlComponent = new com.codename1.ui.html.HTMLComponent();
    htmlComponent.setBodyText(htmlText, "UTF-8");
    final CodenameOneComponentWrapper wrapper = new CodenameOneComponentWrapper(htmlComponent);
    uiPreview.add(java.awt.BorderLayout.CENTER, wrapper);
    wysiwyg.setText(htmlText);
    source.setText(htmlText);
    Listener l = new Listener();
    wysiwyg.getDocument().addDocumentListener(l);
    source.getDocument().addDocumentListener(l);
    JButton b = jToolBar1.add(new StyledEditorKit.BoldAction());
    b.setText("<html><body><b>B</b></body></html>");
    JButton i = jToolBar1.add(new StyledEditorKit.ItalicAction());
    i.setText("<html><body><i>I</i></body></html>");
    JButton u = jToolBar1.add(new StyledEditorKit.UnderlineAction());
    u.setText("<html><body><u>U</u></body></html>");
    jToolBar1.add(new InsertImageAction());
}
项目:freeVM    文件:JEditorPane.java   
@Override
public synchronized void replaceSelection(final String s) {
    if (!isEditable()) {
        new DefaultEditorKit.BeepAction().actionPerformed(null);
        return;
    }
    int start = getSelectionStart();
    int end = getSelectionEnd();
    Document doc = getDocument();
    try {
        if (start != end) {
            doc.remove(start, end - start);
        }
        //May be these attributes placed in Document ????
        AttributeSet as = (editorKit instanceof StyledEditorKit) ? ((StyledEditorKit) editorKit)
                .getInputAttributes()
                : null;
        if (s != null) {
            doc.insertString(start, s, as);
        }
    } catch (BadLocationException e) {
    }
}
项目:freeVM    文件:HTMLEditorKitTest.java   
public void testGetActions() throws Exception {
    Action[] ancestorActions = new StyledEditorKit().getActions();
    Action[] actions = editorKit.getActions();
    assertEquals(12, actions.length - ancestorActions.length);

    Action[] predefinedInsertHTMLTextActions = createPredefinedInsertHTMLTextActions();
    for (int i = 0; i < predefinedInsertHTMLTextActions.length; i++) {
        Action action = findActionWithName(actions,
            predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        if (action != null) {
            assertTrue("Action is not same" + action.getValue(Action.NAME),
                       compareInsertHTMLTextActions(action,
                                                    predefinedInsertHTMLTextActions[i]));
        } else {
            fail("Action not found: " + predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        }
    }
}
项目:freeVM    文件:JEditorPane.java   
@Override
public synchronized void replaceSelection(final String s) {
    if (!isEditable()) {
        new DefaultEditorKit.BeepAction().actionPerformed(null);
        return;
    }
    int start = getSelectionStart();
    int end = getSelectionEnd();
    Document doc = getDocument();
    try {
        if (start != end) {
            doc.remove(start, end - start);
        }
        //May be these attributes placed in Document ????
        AttributeSet as = (editorKit instanceof StyledEditorKit) ? ((StyledEditorKit) editorKit)
                .getInputAttributes()
                : null;
        if (s != null) {
            doc.insertString(start, s, as);
        }
    } catch (BadLocationException e) {
    }
}
项目:freeVM    文件:HTMLEditorKitTest.java   
public void testGetActions() throws Exception {
    Action[] ancestorActions = new StyledEditorKit().getActions();
    Action[] actions = editorKit.getActions();
    assertEquals(12, actions.length - ancestorActions.length);

    Action[] predefinedInsertHTMLTextActions = createPredefinedInsertHTMLTextActions();
    for (int i = 0; i < predefinedInsertHTMLTextActions.length; i++) {
        Action action = findActionWithName(actions,
            predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        if (action != null) {
            assertTrue("Action is not same" + action.getValue(Action.NAME),
                       compareInsertHTMLTextActions(action,
                                                    predefinedInsertHTMLTextActions[i]));
        } else {
            fail("Action not found: " + predefinedInsertHTMLTextActions[i].getValue(Action.NAME));
        }
    }
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:incubator-netbeans    文件:DetailsPanel.java   
@Override
public void removeNotify () {
    setEditorKit (new StyledEditorKit ());
    if (hyperlinkListener != null) {
        removeHyperlinkListener (hyperlinkListener);
    }
    scrollPane = null;
    super.removeNotify ();
}
项目:SER316-Dresden    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:SER316-Dresden    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:SER316-Dresden    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:SER316-Munich    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:SER316-Munich    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:SER316-Munich    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e){
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean strike = (StyleConstants.isStrikeThrough(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setStrikeThrough(sas, strike);
        setCharacterAttributes(editor, sas, false);
    }
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e){
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean strike = (StyleConstants.isSubscript(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setSubscript(sas, strike);
        setCharacterAttributes(editor, sas, false);
    }
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e){
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean strike = (StyleConstants.isSuperscript(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setSuperscript(sas, strike);
        setCharacterAttributes(editor, sas, false);
    }
}
项目:SER316-Ingolstadt    文件:HTMLEditor.java   
public void highlight(ActionEvent e){
    JEditorPane editor = getEditor(e);
    if(editor != null){
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        javax.swing.text.DefaultHighlighter.DefaultHighlightPainter highlightPainter =
                   new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);
        try {
            last = editor.getHighlighter().addHighlight(editor.getSelectionStart(), editor.getSelectionEnd(), highlightPainter);
        } catch (BadLocationException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}
项目:Wilmersdorf_SER316    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:Wilmersdorf_SER316    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:Wilmersdorf_SER316    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:Reinickendorf_SER316    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:Reinickendorf_SER316    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:Reinickendorf_SER316    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:Dahlem_SER316    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:Dahlem_SER316    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:Dahlem_SER316    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}
项目:SER316-Aachen    文件:HTMLEditor.java   
public void boldActionB_actionPerformed(ActionEvent e) {
    if (!bold) {
        boldActionB.setBorder(border2);
    } else {
        boldActionB.setBorder(border1);
    }
    bold = !bold;
    boldActionB.setBorderPainted(bold);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Bold, new Boolean(bold));
     */
    new StyledEditorKit.BoldAction().actionPerformed(e);
}
项目:SER316-Aachen    文件:HTMLEditor.java   
public void italicActionB_actionPerformed(ActionEvent e) {
    if (!italic) {
        italicActionB.setBorder(border2);
    } else {
        italicActionB.setBorder(border1);
    }
    italic = !italic;
    italicActionB.setBorderPainted(italic);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Italic, new Boolean(italic));
     */
    new StyledEditorKit.ItalicAction().actionPerformed(e);
}
项目:SER316-Aachen    文件:HTMLEditor.java   
public void underActionB_actionPerformed(ActionEvent e) {
    if (!under) {
        underActionB.setBorder(border2);
    } else {
        underActionB.setBorder(border1);
    }
    under = !under;
    underActionB.setBorderPainted(under);
    /*
     * SimpleAttributeSet attrs = new SimpleAttributeSet();
     * attrs.addAttribute(StyleConstants.Underline, new Boolean(under));
     */

    new StyledEditorKit.UnderlineAction().actionPerformed(e);
}