import java.awt.*;
public class TestFrame extends Frame
{
public static void main(String args[])
{
TestFrame f=new TestFrame();
//创建框架对象
f.setTitle("My first Frame class");
f.setSize(400,300);
//框架大小
f.setLayout(new FlowLayout());
f.setLocation(0,0);
f.setResizable(true);
Label lb1=new Label();
lb1.setAlignment(Label.CENTER);
lb1.setText("My first label");
f.add(lb1);
Button b1=new Button("My first button
中文");
f.add(b1);
TextField t=new TextField();
t.setText("My first String");
f.add(t);
TextArea t1=new TextArea("My first textarea",5,23);
t1.setEditable(true);
//设置多行文本可编辑
f.add(t1);
f.setVisible(true);
}
}
编译,看看效果就行了