首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

怎么设置字体颜色 大小在下面程序中 急忘解决

2012-02-05 
如何设置字体颜色 大小在下面程序中 急忘解决import javax.swing.*public class TextMove{JLabel labint

如何设置字体颜色 大小在下面程序中 急忘解决
import javax.swing.*;

public class TextMove
{
  JLabel lab;
  int i;
  String str;
   
  public TextMove()
  {
  JFrame frame = new JFrame("TextMove");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400,200);
  // Font f=new Font("")
  str = "I'm moving...";
  lab = new JLabel(str);
  frame.add(lab);
  frame.setVisible(true);
  i=0;
  while(true)
  {
   
  str = " "+str;  
  try
  {
  Thread.sleep(200);
  lab.setText(str);
  }
  catch(InterruptedException e)
  {
  }
  }
  }
   
  public static void main(String args[])
  {
  new TextMove();
  }
}


[解决办法]
你是要对lab设置字体吗,
我是这样写的:
label.setFont(new Font("宋体", Font.ITALIC, 8));

这个label的字体是宋体,斜体,8号字

热点排行