package cn.puruidong.Test;
import java.awt.*;
public class Gui{
private Frame f;
private Button b1;
private Button b2;
public static void main(String args[]){ Gui that = new Gui();
that.go();
}
public void go(){ //这个地方编译器不通过
f = new Frame("GUI example");
f.setLayout(new FlowLayout());
//设置布局管理器为FlowLayout
b1 = new Button("Press Me"); //按钮上显示字符"Press Me"
b2 = new Button("Don't Press Me");
f.add(b1);
f.add(b2);
f.pack();//紧凑排列,其作用相当于setSize(),即让窗口尽量小,小到刚刚能够包容住b1、b2两个按钮
f.setVisible(true);
}
}
求高手解答。。
private Frame f;
private Button b1;
private Button b2;
public void go(){ //这个地方编译器不通过
f = new Frame("GUI example");
f.setLayout(new FlowLayout());
//设置布局管理器为FlowLayout
b1 = new Button("Press Me"); //按钮上显示字符"Press Me"
b2 = new Button("Don't Press Me");
f.add(b1);
f.add(b2);
f.pack();//紧凑排列,其作用相当于setSize(),即让窗口尽量小,小到刚刚能够包容住b1、b2两个按钮
f.setVisible(true);
}
public static void main(String[] args) {
Test test = new Test() ;
test.go() ;
}可以通过 刚才拷你代码报错 好像你的结束语句是中文的(就是}这个)
f.setVisible(true);
}