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); //讓組件顯示
}
}
顯示的是一個空白的窗口。