GUI 简单提问 顶者有分.
为辅助回答,张贴以下我编写的简易计算器代码,回答问题可不看.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class SmpCountEquipment2 extends JFrame implements ActionListener {
private TextField Operation1,Operation2,End;
private Button button1,button2,button3,button4;
private Label label1,label2,label3;
SmpCountEquipment2(){
super( "简易计算器 ");
setJLabelJTextFeild();
setJLabelJTextFeild2();
setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
}
public void setJLabelJTextFeild(){
Container c=getContentPane();
JPanel panel1=new JPanel();
label1=new Label( " 操作数 ");
Operation1=new TextField(20);
label2=new Label( " 操作数 ");
Operation2=new TextField(20);
label3=new Label( " 结果 ");
End=new TextField(20);
GridLayout g=new GridLayout(3,3,50,50);
panel1.setLayout(g);
panel1.add( label1);
panel1.add(Operation1);
panel1.add(label2);
panel1.add(Operation2);
panel1.add(label3);
panel1.add( End);