JButton 和其他的组件一样,也位于 java.awt.swing包中

  在容器中添加组件时,不需要知名组件容器显示的位置,组件的布局由被称为布局管理器的对象决定

  最简单的布局管理器是FlowLayout类,被称为流布局管理器,位于java.awt 包中。

  FlowLayout fff=new FlowLayout();

     panel.setLayout(fff);//将容器panl的布局管理器设置为fff

 

  Playback.java程序

  import javax.swing.*;

  import java.awt.*;

  public class Playback extends JFrame

  {

    public Playback()

    {

       super("Playback");

         this.setsize(225,80);

       this.setDefalutCloseOperation(JFrame.EXIT_ON_CLOSE);

       this.setVisible(true);

       FlowLayout f=new FlowLayout(FlowLayout.CENTER,10,10);//后面两个参数是代表横向和纵向的控件像个距离

       this.setLayout(f);

       JButton f=new JButton("play");

       JButton f1=new JButton("stop");

       JButton f2=new JButton("resert");

       this.add(f);

       this.add(f1);

       this.add(f2);

    }

    public static void main(String[] arguments)

    {

      new Playbak();

    }

  }