import javax.swing.JFrame;
class Frame extends JFrame{
 Frame(){
                // 關閉視窗小圖示 X 的設定
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                // 設定視窗大小,(200,200)視窗左上角(x,y)坐標,450 寬度,300 高度
  setBounds(200,200,450,300);   
  setTitle("Swing JFrame 視窗"); // 視窗標題
  setVisible(true); // 顯示視窗
 }
}
public class FrameTest {
 public static void main(String[] args) {
  Frame frame = new Frame();
 }
}
執行結果

沒有留言:
張貼留言