//网格布局管理器
import java.awt.*;import javax.swing.*;public class Jiemian3 extendsJFrame{//定义组件
JButton[] an = {null,null,null,null,null,null,null,null};public static voidmain(String[] args){//运行本类的构造方法
Jiemian3 jiemian = newJiemian3();
}publicJiemian3(){//创建按钮
an[0] = new JButton("话梅");
an[1] = new JButton("果铺");
an[2] = new JButton("薯片");
an[3] = new JButton("饼干");
an[4] = new JButton("巧克力");
an[5] = new JButton("腰果");
an[6] = new JButton("锅巴");
an[7] = new JButton("开心果");//网格布局管理器声明//第一个参数是行,第二个参数是列,第三个参数是横间距,第四个参数是竖间距
this.setLayout(new GridLayout(3,3,15,15));//添加按钮
this.add(an[0]);this.add(an[1]);this.add(an[2]);this.add(an[3]);this.add(an[4]);this.add(an[5]);this.add(an[6]);this.add(an[7]);//设置窗口标题
th