游泳时遇到漩涡怎么办:请问这个程序错在哪?(JAVA)

来源:百度文库 编辑:中科新闻网 时间:2024/05/14 06:41:50
import java.awt.*;
public class exec
{
public static void main(String args[])
{
Frame f=new Frame("This is a window!");
f.setLocation(100,200);
f.setSize(200,400);
f.setBackground(Color.red);

FlowLayout fl=new FlowLayout();
f.setLayout(fl);

Button[] barray=new Button[10];
for(int i=0;i<barray.length;i++)
{
barray=new Button();
barray.setLabel(String.valueOf(i));
f.add(barray);
}

f.setVisible(true);
}
}

import java.awt.*;
public class exec
{

public static void main(String args[])
{
Frame f=new Frame("This is a window!");
f.setLocation(100,200);
f.setSize(200,400);
f.setBackground(Color.red);

FlowLayout fl=new FlowLayout();
f.setLayout(fl);

Button barray;
for(int i=0;i<10;i++)
{
barray=new Button();
barray.setLabel(String.valueOf(i));
f.add(barray);
}

f.setVisible(true);
}
}

检查一下第二个大括号..

缺少监听器.