java的一个找错误的小程序,大家看一下。
import java.awt.Frame;import java.awt.Label;
import java.awt.Button;
import java.awt.FlowLayout;
class L7_1 extends Frame{
FlowLayout flowLayout1=new FlowLayout();
Button button1=new Button();
Button button2=new Button();
Button button3=new Button();
Label label1=new Label();
L7_1(){
super("FlowLayout 实例");
Init();
}
void Init() throws Exception{
button1.setLabel("one");
this.getContentPane().setLayout(flowLayout1);
button2.setLabel("two");
button3.setLabel("three");
label1.setLocale(java.util.Locale.getDefault());
label1.setText("这是使用了FlowLayout的左对齐方式");
flowLayout1.setAlignment(FlowLayout.LEFT);
this.getContentPane().add(button1,null);
this.getContentPane().add(button2,null);
this.getContentPane().add(button3,null);
this.getContentPane().add(label1,null);
this.setSize(250,250);
}
public static void main(String args[]){
L7_1 exam7_1=new L7_1();
exam7_1.show();
}
}