Frame Preliminary (2)

package testDemo1;

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;

public class FrameTest {

	public static void main(String[] args) {
		Frame f = new Frame("My first window");//The window is not displayed by default
		f.setSize(400, 600);//Set the window size
		f.setLocation(500,50);//Set the window display location
		f.setVisible(true);//Display the window
		
		Button but = new Button("my button");//If the button is set to Chinese, garbled characters may appear
		f.setLayout(new FlowLayout());//The default is a border layout (the button is huge), so you need to set the layout in the main panel
		f.add(but);

	}

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326352649&siteId=291194637