Package fifth day; import Java.awt.toolkit;import Javax.swing.jframe;public class MainFrame extends JFrame {public MainFrame () {This.settitle ("airplane frame");//title This.setsize (800, 600);//The form size//The following two lines of comment can also be used to control where the form is displayed//toolkit TL = Toolkit.getdefaulttoolkit ();//this.setlocation ((Tl.getscreensize (). width-800)/2, (Tl.getscreensize (). height-600 )/2); This.setlocationrelativeto (null);//center, equivalent to the two lines of code above commented this.setresizable (false);//Make it unable to change the size of the form//the following line of code in parentheses can also be written in 3 , because when you hold down CTRL and click Exit_on_close, you will see//to Jframe.class inside the definition is public static final int exit_on_close = 3; This.setdefaultcloseoperation (jframe.exit_on_close);//make its true close form this.setvisible (TRUE);//Show Form//this.show (); This is out of date. }public static void Main (string[] args) {new MainFrame (), because it is unsafe, cannot be used again;/}}
Basic frame of a flying game: fixed form position, cannot change form size arbitrarily