Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://blog.sina.com.cn/s/blog_025270e90101b1db.html
- //https://bbs.csdn.net/topics/380242077
- package com.sample;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.Label;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- /**
- *
- * @author Hsiang-Yu Kuo
- */
- public class AWTGUI1 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // -Dfile.encoding=GB18030
- Frame frame = new Frame("標題 Frame");
- Label label = new Label();// 建立標籤物件label
- frame.setSize(400, 300);
- frame.setLocation(400, 400);// 設定視窗位置
- frame.setBackground(Color.white);
- // label.setText("中文字 label");// 在標籤內加上文字
- // label.setText(new String("中文字 label".getBytes("UTF-8"), "big5"));//在標籤內加上文字
- label.setText("中文字 简体字 label");// 在標籤內加上文字
- // label.setBackground(Color.white);//設定標籤底色為白色
- label.setBackground(new Color(255, 255, 255));// 設定標籤底色為白色
- label.setAlignment(Label.CENTER);// 將標籤內的文字置中
- label.setForeground(Color.black);// 設定標籤文字
- // Font font = new Font("DialogInput", Font.ITALIC + Font.BOLD, 18);
- Font font = new Font("DialogInput", Font.PLAIN, 28);
- // Font font = new Font("標楷體", Font.PLAIN, 24);
- // Font font = new Font("Consolas", Font.PLAIN, 18);
- label.setFont(font);// 設定字型的樣式
- frame.add(label);
- frame.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
- frame.setVisible(true);
- }// end of main method
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement