public class Mb extends Applet { public void init() {
FlowLayout flow=new FlowLayout();
flow.setAlignment(FlowLayout.LEFT);
flow.setHgap(20);
flow.setVgap(40);
setLayout(flow);//为什么不是用flow.setLayout(flow);
for(int i=1;i<=12;i++)
{
add(new Button("i am "+i));//为什么不是用flow.add(new Button("i am "+i));
}
}
}
FlowLayout flow=new FlowLayout();
flow.setAlignment(FlowLayout.LEFT);
flow.setHgap(20);
flow.setVgap(40);
setLayout(flow);//为什么不是用flow.setLayout(flow);
for(int i=1;i<=12;i++)
{
add(new Button("i am "+i));//为什么不是用flow.add(new Button("i am "+i));
}
}
}
setLayout(flow);//为什么不是用flow.setLayout(flow);这是什么意思。
flow自己设置自己???
add(new Button("i am "+i));//为什么不是用flow.add(new Button("i am "+i));flow只是设置Applet的布局,最后还得把组件加到Applet上,不是加到布局上
第二··道理是一样的··意思是给当前对象添加button··
同样Button放哪里也知道了吧
Container container=getContentPane();
container.setLayout(new FlowLayout(FlowLayout.CENTER,10,20));
这里省去container可不可以?有什么区别
flow.setAlignment(FlowLayout.LEFT);
flow.setHgap(20);
flow.setVgap(40);
setLayout(flow);//为什么不是用flow.setLayout(flow);
for(int i=1;i<=12;i++)
{
add(new Button("i am "+i));//为什么不是用flow.add(new Button("i am "+i));
}
}
}
容器是哪个?
cp.setLayout(flow);