How to create a JFrame

import java.awt.*;
import javax.swing.*;
/*Thanh Lai*/
public class MyWindow extends JFrame{
    public MyWindow(){
        super("Demo My Window"); //title bar attribute
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
    public static void main(String[] args){
        MyWindow thanh = new MyWindow();    //create a frame
        thanh.setSize(400,400);       
        thanh.setLocationRelativeTo(null);    //display the window on the center of the screen
        thanh.setVisible(true);                //show the window
    }
   
}

Output

No Response to "How to create a JFrame"

Post a Comment

 

Copyright © 2013-2014 Lai Duy Thanh All rights reserved.