|
|
@ -37,7 +37,7 @@ public class Calculator extends JFrame implements ActionListener {
|
|
|
|
|
|
|
|
|
|
|
|
add(panel, BorderLayout.CENTER);
|
|
|
|
add(panel, BorderLayout.CENTER);
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
setSize(800, 500); // 设置窗口大小为宽800像素,高500像素
|
|
|
|
setSize(1000, 600); // 设置窗口大小为宽800像素,高500像素
|
|
|
|
setLocationRelativeTo(null); // 窗口居中显示
|
|
|
|
setLocationRelativeTo(null); // 窗口居中显示
|
|
|
|
pack();
|
|
|
|
pack();
|
|
|
|
setVisible(true);
|
|
|
|
setVisible(true);
|
|
|
@ -99,7 +99,11 @@ public class Calculator extends JFrame implements ActionListener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
textField.setText("" + result);
|
|
|
|
if (result == Math.floor(result)) {
|
|
|
|
|
|
|
|
textField.setText(String.valueOf((int) result));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
textField.setText(String.valueOf(result));
|
|
|
|
|
|
|
|
}
|
|
|
|
operator = "";
|
|
|
|
operator = "";
|
|
|
|
calculating = true;
|
|
|
|
calculating = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|