返回列表 發帖
  1. import javax.swing.JFrame;
  2. import javax.swing.JLabel;
  3. import java.awt.GridLayout;
  4. import javax.swing.border.EtchedBorder;
  5. import java.awt.Color;
  6. import java.awt.Font;
  7. public class Ch01 {
  8.         
  9.         Font ft[]=new Font[6];
  10.         JLabel lb[]=new JLabel[6];
  11.         JFrame fm;

  12.         Ch01()
  13.         {
  14.             ft[0]=new Font("標楷體",Font.BOLD, 50);
  15.             ft[1]=new Font("微軟正黑體",Font.BOLD+Font.ITALIC, 40);
  16.             ft[2]=new Font("新細明體",Font.ITALIC, 60);
  17.             ft[3]=new Font("Times New Roman",Font.PLAIN, 40);
  18.             ft[4]=new Font("Arial",Font.ITALIC, 60);
  19.             ft[5]=new Font("Freestyle Script",Font.PLAIN, 80);
  20.                
  21.             for(int i=0; i<6; i++){
  22.                     if(i<3)
  23.                             lb[i]=new JLabel("你好",JLabel.CENTER);
  24.                     else
  25.                             lb[i]=new JLabel("hello",JLabel.CENTER);
  26.                     lb[i].setBorder(new EtchedBorder());
  27.                     lb[i].setFont(ft[i]);
  28.             }
  29.             
  30.             lb[0].setForeground(Color.BLUE);
  31.             lb[2].setForeground(Color.RED);
  32.             lb[4].setForeground(Color.GRAY);
  33.             
  34.                 fm=new JFrame("");
  35.             fm.setBounds(100, 100, 450, 300);
  36.             fm.setVisible(true);
  37.             fm.setResizable(true);
  38.             fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  39.             fm.setLayout(new GridLayout(2,3));
  40.             for(int i=0; i<6; i++)
  41.                     fm.add(lb[i]);

  42.         }
  43.         
  44.         public static void main(String[] args) {
  45.                 new Ch01();
  46.         }
  47. }
複製代碼
كخخخخخخخخخخخخخ

TOP

返回列表