求大神解答。。急!!!!考试中谢谢。 50
Java程序代码:
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class test extends JFrame {
private static final long serialVersionUID = 1L;
JTextField txtNum1, txtNum2, txtResult;
JLabel lblNum1, lblNum2, lblResult;
public test() {
super("张三01号");
txtNum1 = new JTextField(5);
txtNum2 = new JTextField(5);
txtResult = new JTextField(5);
lblNum1 = new JLabel("第一个数:");
lblNum2 = new JLabel("第二个数:");
lblResult = new JLabel("结果为:");
setLayout(new GridLayout(3, 2));
add(lblNum1);
add(txtNum1);
add(lblNum2);
add(txtNum2);
add(lblResult);
add(txtResult);
setSize(300, 200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new test();
}
}
运行效果: