这个界面出了这个问题,什么情况?怎么处理,如何将这个程序做的更好看一些。位置怎么设置。挺急的,谢谢各位大佬
package com.demo;
import java.awt.BorderLayout;
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.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class demo {
public static void main(String[] str) {
final JFrame frame = new JFrame();
frame.setSize(1000, 1000);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(true);
JPanel panel = new JPanel();
JLabel labeltitle=new JLabel("17网蒙 山常钢 777777777");
JLabel label = new JLabel(" 请输入第一个数 ");
final JTextField input1 = new JTextField(10);
JLabel label2 = new JLabel(" 请输入第二个数 ");
final JTextField input2 = new JTextField(10);
final JTextField sum = new JTextField(10);//加
final JTextField jian = new JTextField(10);//减
final JTextField cheng = new JTextField(10);//乘
final JTextField chu = new JTextField(10);//除
sum.setEditable(false);
JButton button = new JButton("等于");
panel.add(labeltitle);
panel.add(label);
panel.add(input1);
panel.add(label2);
panel.add(input2);
panel.add(button);
panel.add(sum);
panel.add(jian);
panel.add(cheng);
panel.add(chu);
button.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0) {
String str1 = input1.getText().trim();
String str2 = input2.getText().trim();
try {
double in1 = Integer.parseInt(str1);
double in2 = Integer.parseInt(str2);
sum.setText("" + (in1 + in2));
jian.setText("" + (in1 - in2));
cheng.setText("" + (in1 * in2));
chu.setText("" + (in1 / in2));
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(frame, "输入错误信息!");
}
}
});
frame.add(panel, BorderLayout.NORTH );
frame.setVisible(true);
}
}