接上个帖子 这个类是CSDN网友5斗米的 我照搬过来了
class FontAttrib {
  public static final int GENERAL = 0; // 常规
  public static final int BOLD = 1; // 粗体
  public static final int ITALIC = 2; // 斜体
  public static final int BOLD_ITALIC = 3; // 粗斜体

  private SimpleAttributeSet attrSet = null; // 属性集
  private String text = null; // 要输入的文本
  private int style = 0, size = 0; // 样式和字号
  private Color color = null; // 文字颜色
  private int colorNum = 0; 
  /**
   *构造方法(空)
   */
  public FontAttrib() {
 }

  /**
   * 返回属性集
   *
   * @return
   */
  public SimpleAttributeSet getAttrSet() {
   attrSet = new SimpleAttributeSet();
  
   if (style == FontAttrib.GENERAL) {
    StyleConstants.setBold(attrSet, false);
    StyleConstants.setItalic(attrSet, false);
   } else if (style == FontAttrib.BOLD) {
    StyleConstants.setBold(attrSet, true);
    StyleConstants.setItalic(attrSet, false);
   } else if (style == FontAttrib.ITALIC) {
    StyleConstants.setBold(attrSet, false);
    StyleConstants.setItalic(attrSet, true);
   } else if (style == FontAttrib.BOLD_ITALIC) {
    StyleConstants.setBold(attrSet, true);
    StyleConstants.setItalic(attrSet, true);
   }
   StyleConstants.setFontSize(attrSet, size);
   if (color != null)
    StyleConstants.setForeground(attrSet, color);
   return attrSet;
  }

  /**
   * 设置属性集
   *
   * @param attrSet
   */
  public void setAttrSet(SimpleAttributeSet attrSet) {
   this.attrSet = attrSet;
  }

 
  public void setColorNum(int i) {
  	this.colorNum = i;
  }
  public int getColorNum() {
  	return colorNum;
  }
  
  public String getText() {
   return text;
  }

  public void setText(String text) {
   this.text = text;
  }

  public Color getColor() {
   return color;
  }

  public void setColor(Color color) {
   this.color = color;
  }

  public int getSize() {
   return size;
  }

  public void setSize(int size) {
   this.size = size;
  }

  public int getStyle() {
   return style;
  }

  public void setStyle(int style) {
   this.style = style;
  }
 
 }