用JAVA设计一个加法运算器

来源:百度知道 编辑:UC知道 时间:2024/05/28 13:16:14
在文本框中输入两个整数,单击"="在第三个文本框中显示和~~~~
太长,运行时候都有问题啊~~~~还不知道怎么改~~

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Computer extends JFrame{
private Container contentPane = null;
private JPanel computerPanel = null;
private JPanel buttonPanel = null;
private JTextField sourceField1 = null;
private JTextField sourceField2 = null;
private JTextField resultField = null;
private JLabel addLabel = null;
private JLabel resultLabel = null;
private JButton submitButton = null;
private JButton resetButton = null;

public Computer(){
this.setSize(200,200);
this.setLocation(350,150);
this.init();
this.setVisible(true);
}

public void init(){
contentPane = this.getContentPanel();
contentPane.setLayout(new GridLayout(2,1));
computerPanel = new JPanel(new FlowLayout(20,20));
buttonPanel = new JPanel(new FlowLayout(50,25));
sourceField1 = new JTextField(5);
sourceF