- 1、本文档共30页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
简易java计算嚣(国外英文资料)
简易java计算嚣(国外英文资料)
Simple calculation tao
Simple calculation tao
[file] calculatortest.java
The view sourceprint?
001
Package com. Hundsun. Paybf. Test;
002
003
Import the Java. The awt. BorderLayout.
004
Import the Java. The awt. Dimension;
005
Import the Java. The awt. GridLayout;
006
Import the Java. The awt. Toolkit;
007
Import the Java. The awt. Event. An ActionEvent;
008
Import the Java. The awt. Event. ActionListener;
009
010
The import javax.mail. Swing. JButton;
011
The import javax.mail. Swing. JFrame;
012
The import javax.mail. Swing. JPanel;
013
The import javax.mail. Swing. SwingUtilities;
014
The import javax.mail. Swing. UIManager;
015
016
The class CalculatorPanel extends JPanel {
017
Private JPanel jp. / / in the middle panel
018
Private double the result; / / calculation
019
Private Boolean start; / / for the first time, true for the first time, false is not the first time
020
Private Boolean flag. / / to determine whether to empty the display area value, true needs, false does not need
021
Private String lastCommand; / / to save the operator
022
JButton display; / / display area
023
024
Public CalculatorPanel () {
025
/ / initialize the values
026
Result = 0;
027
Start = true;
028
Flag = false;
029
LastCommand = =;
030
031
/ / set the layout of this panel of CalculatorPanel for the framework layout
032
The new BorderLayout ());
033
/ / this button is used to display the area of the value
034
Display = new JButton ( 0.0 );
035
Display. SetEnabled (false); / / button style is set to disable style
036
037
/ / for initialization, removal
038
JButton clear = new JButton ( clear );
039
So, clear.addactionlistener
040
@ Override
041
Public void actionPerformed (ActionEvent e)
042
/ / do the initialization
043
Result = 0;
044
Start = true;
045
Flag = false;
046
LastCommand = =;
047
Sett.settext ( 0.0 );
048
}
049
});
050
051
Jp = new JPanel ();
052
/ / set this panel layout to the grid layout, 4 rows 4 columns
053
New GridLayout (4, 4));
054
055
/ / instan
文档评论(0)