- import javax.swing.*;
- import java.awt.*;
- import javax.swing.border.EtchedBorder;
- public class Ch119 {
- private JFrame f;
- private JLabel lb[]=new JLabel[6];
- private Font ft[]=new Font[6];
- Ch119()
- {
- ft[0]=new Font("標楷體",Font.BOLD,50);
- ft[1]=new Font("微軟正黑體",Font.BOLD+Font.ITALIC,40);
- ft[2]=new Font("新細明體",Font.ITALIC,60);
- ft[3]=new Font("Times New Roman",Font.PLAIN,40);
- ft[4]=new Font("Arial",Font.ITALIC,60);
- ft[5]=new Font("Freestyle script",Font.PLAIN,80);
- for(int i=0;i<6;i++)
- {
- if(i<3)
- lb[i]=new JLabel("你好",JLabel.CENTER);
- else
- lb[i]=new JLabel("Hello",JLabel.CENTER);
- lb[i].setFont(ft[i]);
- lb[i].setBorder(new EtchedBorder());
- }
- f=new JFrame("\u30df\udcef");
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- f.setResizable(true);
- f.setVisible(true);
- f.setBounds(100,100,300,200);
- f.setLayout(new GridLayout(2,3));
- for(JLabel i:lb)
- f.add(i);
- }
- public static void main(String[] args) {
- new Ch119();
- }
- }
複製代碼 |