📄 -
字号:
b<I>.setBackground(Color.lightGray);<BR>
b<I>.setForeground(Color.blue);<BR>
}<BR> <BR>
for(int
i=4;i<15;i=i+5)<BR>
{<BR>
b<I>.setBackground(Color.lightGray);<BR>
b<I>.setForeground(Color.red); <BR>
}<BR> <BR>
for(int i=17;i<21;i++)<BR>
{<BR>
b<I>.setBackground(Color.lightGray);<BR>
b<I>.setForeground(Color.blue);<BR>
}<BR> <BR>
for(int i=19;i<21;i++)<BR>
{<BR>
b<I>.setBackground(Color.lightGray);<BR>
b<I>.setForeground(Color.red);<BR>
}<BR> <BR>
for(int i=1;i<4;i++)<BR>
{<BR>
b[i*5].setBackground(Color.lightGray);<BR>
b[i*5].setForeground(Color.blue);<BR>
}<BR>
<BR>
f.add(tf,"North");<BR>
p.add(p1,"Center");<BR>
p.add(p2,"North");<BR>
p.add(p3,"West");<BR>
f.add(p,"Center");<BR>
f.pack();<BR>
f.setResizable(false);<BR>
f.setVisible(true);<BR>
f.addWindowListener(new WindowAdapter()<BR>
{<BR>
public void windowClosing(WindowEvent
e)<BR>
{<BR>
System.exit(1);<BR>
} <BR>
});<BR> }<BR> <BR>
public void actionPerformed(ActionEvent
e)<BR> { <BR>
s = e.getActionCommand();<BR>
String s1 = tf.getText();<BR>
<BR><BR>
if(s=="0"|s=="1"|s=="2"|s=="3"|s=="4"|s=="5"|s=="6"|s=="7"|s=="8"|s=="9")<BR>
{<BR>
if(flag)<BR>
{<BR>
tf.setText(s1 + s);<BR>
}<BR>
else<BR>
{<BR>
tf.setText(s);<BR>
flag =
true;<BR>
}<BR> }<BR>
<BR> else
if(s=="+"|s=="-"|s=="*"|s=="/")<BR>
{<BR>
result = Double.parseDouble(s1);<BR>
flag = false;<BR>
oper = s;<BR>
}<BR>
<BR> else
if(s=="=")<BR> {<BR>
tmp1 =
Double.parseDouble(tf.getText());<BR>
if(oper == "+") result +=
tmp1;<BR>
if(oper == "-") result -= tmp1;<BR>
if(oper == "*") result *=
tmp1;<BR>
if(oper == "/") result /= tmp1;<BR>
tf.setText(Double.toString(result));<BR>
oper = "";<BR>
flag = false;<BR>
}<BR>
<BR> else
if(s=="+/-")<BR> {<BR>
tmp2 =
-1*Double.parseDouble(tf.getText());<BR>
tf.setText(Double.toString(tmp2));<BR>
}<BR>
<BR> else
if(s=="sqrt")<BR> {<BR>
tmp3 =
Double.parseDouble(tf.getText());<BR>
if(tmp3>0)<BR>
{<BR>
tmp3 =
Math.sqrt(tmp3);<BR>
tf.setText(Double.toString(tmp3));<BR>
flag =
false;<BR>
}<BR>
else{}<BR> }<BR>
<BR> else
if(s=="1/x")<BR> {<BR>
tmp4 =
1/Double.parseDouble(tf.getText());<BR>
tf.setText(Double.toString(tmp4));<BR>
flag = false;<BR>
}<BR>
<BR> else
if(s=="%")<BR> {<BR>
tmp5 =
Double.parseDouble(tf.getText())/100;<BR>
if(oper == "*")<BR>
{<BR>
result =
result*(result*tmp5);<BR>
tf.setText(Double.toString(result));<BR>
}<BR>
else if(oper == "+")<BR>
{<BR>
result =
result+result*tmp5;<BR>
tf.setText(Double.toString(result));<BR>
}<BR>
else if(oper == "-")<BR>
{<BR>
result =
result-result*tmp5;<BR>
tf.setText(Double.toString(result));<BR>
}<BR>
else if(oper == "/")<BR>
{<BR>
result =
result/(result*tmp5);<BR>
tf.setText(Double.toString(result));<BR>
}<BR>
else<BR>
{<BR>
tf.setText("0.0");<BR>
}<BR>
flag = false;<BR>
oper = "";<BR>
}<BR>
<BR> else if(s=="
退格 ")<BR> {<BR>
String after =
s1.substring(0,(s1.length()-1));<BR>
tf.setText(after);<BR>
}<BR>
<BR> else
if(s==".")<BR> {<BR>
if(s1.indexOf('.')==-1)<BR>
{<BR>
tf.setText(s1+s);<BR>
}<BR>
else{} <BR>
}<BR>
<BR> else if(s=="
CE "|s==" C
")<BR> {<BR>
tf.setText("0");<BR>
flag = false;<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -