我投诉~怎么我提的十几个问题没人复?

解决方案 »

  1.   

    private void setTextColor(final JTextPane sourcePane,
            final int offset, final int endPos,
                              final Color color) {
        SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        MutableAttributeSet attr = new SimpleAttributeSet();
        StyleConstants.setForeground(attr, color);
        if (offset != endPos) {
            StyledDocument doc = (StyledDocument) sourcePane.getDocument();
         doc.setCharacterAttributes(offset, endPos - offset, attr, false);
    }
    }
    });
    }