Java(42)_不使用布局管理器

package MYSQK.example01;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 不使用布局管理器
 */

public class example01 {
  public  static  void  main(String[] args){
    Frame f = new Frame("不使用布局管理器");
    f.setLayout(null);//取消frame的布局管理器
      f.setSize(300,150);
      Button button1 =new Button("press");
      Button button2 =new Button("pop");
      //设置按钮显示位置和大小
      button1.setBounds(40,60,100,30);
      button2.setBounds(140,90,100,30);
      // 添加按钮到窗体
      f.add(button1);
      f.add(button2);
      f.setVisible(true);
  }
}

 

   不使用布局管理器是不是更灵活一些呢?还有就是其实javaGUI确实用的少了。现在很多项目都是B/S架构的,通过浏览器,除非是写个小工具啥的可能会用到。

posted @ 2018-11-28 22:21  sunnybowen  阅读(504)  评论(0编辑  收藏  举报