swing組件基礎(1)

import java.awt.Color;
import javax.swing.JFrame;
public class firstJFrame {
public static void main(String args[]) {
JFrame frame = new JFrame("The first swing example"); //設置實例化對象,並且標題顯示爲"The first swing example"
frame.setSize(300,200); //設置窗口大小
frame.setBackground(Color.blue); //設置窗口的顏色
frame.setLocation(300, 200); //顯示窗口的位置
frame.setVisible(true); //讓組件顯示
}

}


顯示的是一個空白的窗口。

發佈了27 篇原創文章 · 獲贊 17 · 訪問量 16萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章