字符串只是保存 String 的地方。
没有什么颜色的。

解决方案 »

  1.   

    可以在  public void paintComponent(Graphics g)
       {
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D)g;
          g2.setPaint(Color.BLUE);//改变颜色
          //改变画笔的字体,包括斜体和粗体和大小等
          Font font = new Font("Courier",Font.ITALIC | Font.BOLD,11);
          g2.setFont(font);   }
      

  2.   

    如果是JLabel的话, 可以这样写
    label.setText("<html><font color="#123456">abc</font></html>");