本文主要是介绍GUI----初期界面,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import java.awt.*; import java.awt.event.*; /** * Created by lenovo on 2017/9/13. */ public class AwtDemo {public static void main(String[] args) {Frame frame = new Frame("窗口"); frame.setSize(400, 300);//大小 frame.setLocation(300, 300);//边距 frame.setLayout(new FlowLayout());//接下来布局 Button button = new Button("我是按钮"); frame.add(button); // frame.addWindowListener(new MyWin()); frame.addWindowListener(new WindowAdapter() {@Override public void windowOpened(WindowEvent e) {System.out.println("我被打开了"); }@Override public void windowClosing(WindowEvent e) {System.out.println("我关"); System.exit(0); }@Override public void windowActivated(WindowEvent e) {System.out.println("我被前置界面了"); }}); frame.setVisible(true); }}
这篇关于GUI----初期界面的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!