import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MultipleGUI {
private static JTextField one = new JTextField(4);
private static JTextField two = new JTextField(4);
private static JTextField result = new JTextField(8);
public static void main(String[] args) {
JFrame frame = new JFrame("简易计算器");
frame.setLayout(new FlowLayout(FlowLayout.CENTER));
frame.add(one);
frame.add(new JLabel("*"));
frame.add(two);
frame.add(new JLabel("="));
frame.add(result);
JButton button = new JButton("计算");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
result.setText(String.valueOf(Integer.parseInt(one.getText()) * Integer.parseInt(two.getText())));
}
});
frame.add(button);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}