当我尝试将日食源代码传输到dr.java时,第一行“软件包TrigonometricCalculators;”不起作用。
编译器给我
“文件:C:\ Users \ TwlEm \ Desktop \ TrigCalculators.java [行:(无源位置)] 错误:文件位于错误的目录中或被声明为错误的软件包的一部分。目录名称“桌面”与软件包名称“ TrigonometricCalculators”不匹配。”
在我自己的PC上,我删除了该错误行,并且可以运行,但是当我在学校计算机上这样做时,我的整个程序崩溃了。如何解决这个问题呢?
package TrigonometricCalculators;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.*;
public class TrigCalculators {
private JFrame frame;
private StringBuilder sBuilder = new StringBuilder();
double firstnum;
double secondnum;
String operations;
double result;
String answer;
double product=1;
static boolean equalsAlreadyPressed = false;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TrigCalculators window = new TrigCalculators();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public TrigCalculators() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 473, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JButton btn0 = new JButton("0");
btn0.setBounds(35, 438, 55, 55);
btn0.setFont(new Font("Tahoma", Font.BOLD, 16));
btn0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("0");
lblNewLabel.setText(sBuilder.toString());
}
});
btn0.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn0);
JButton btn1 = new JButton("1");
btn1.setBounds(35, 372, 55, 55);
btn1.setFont(new Font("Tahoma", Font.BOLD, 16));
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("1");
lblNewLabel.setText(sBuilder.toString());
}
});
btn1.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn1);
JButton btn2 = new JButton("2");
btn2.setBounds(100, 372, 55, 55);
btn2.setFont(new Font("Tahoma", Font.BOLD, 16));
btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("2");
lblNewLabel.setText(sBuilder.toString());
}
});
btn2.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn2);
JButton btn3 = new JButton("3");
btn3.setBounds(165, 372, 55, 55);
btn3.setFont(new Font("Tahoma", Font.BOLD, 16));
btn3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("3");
lblNewLabel.setText(sBuilder.toString());
}
});
btn3.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn3);
JButton btn4 = new JButton("4");
btn4.setBounds(35, 306, 55, 55);
btn4.setFont(new Font("Tahoma", Font.BOLD, 16));
btn4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("4");
lblNewLabel.setText(sBuilder.toString());
}
});
btn4.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn4);
JButton btn5 = new JButton("5");
btn5.setBounds(100, 306, 55, 55);
btn5.setFont(new Font("Tahoma", Font.BOLD, 16));
btn5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("5");
lblNewLabel.setText(sBuilder.toString());
}
});
btn5.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn5);
JButton btn6 = new JButton("6");
btn6.setBounds(165, 306, 55, 55);
btn6.setFont(new Font("Tahoma", Font.BOLD, 16));
btn6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("6");
lblNewLabel.setText(sBuilder.toString());
}
});
btn6.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn6);
JButton btn7 = new JButton("7");
btn7.setBounds(35, 240, 55, 55);
btn7.setFont(new Font("Tahoma", Font.BOLD, 16));
btn7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("7");
lblNewLabel.setText(sBuilder.toString());
}
});
btn7.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn7);
JButton btn8 = new JButton("8");
btn8.setBounds(100, 240, 55, 55);
btn8.setFont(new Font("Tahoma", Font.BOLD, 16));
btn8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("8");
lblNewLabel.setText(sBuilder.toString());
}
});
btn8.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn8);
JButton btn9 = new JButton("9");
btn9.setBounds(165, 240, 55, 55);
btn9.setFont(new Font("Tahoma", Font.BOLD, 16));
btn9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append("9");
lblNewLabel.setText(sBuilder.toString());
}
});
btn9.setBackground(SystemColor.controlHighlight);
frame.getContentPane().add(btn9);
JButton button = new JButton("");
button.setFont(new Font("Tahoma", Font.BOLD, 11));
button.setBackground(SystemColor.inactiveCaption);
button.setBounds(360, 110, 55, 43);
frame.getContentPane().add(button);
JButton btnsin = new JButton("sin");
btnsin.setBounds(35, 169, 55, 55);
btnsin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("sin");
operations ="sin" ;
equalsAlreadyPressed = false;
}
});
btnsin.setFont(new Font("STXinwei", Font.BOLD, 13));
btnsin.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnsin);
JButton btncos = new JButton("cos");
btncos.setBounds(100, 169, 55, 55);
btncos.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("cos");
operations ="cos" ;
equalsAlreadyPressed = false;
}
});
btncos.setFont(new Font("STXinwei", Font.BOLD, 13));
btncos.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btncos);
JButton btnTan = new JButton("tan");
btnTan.setBounds(165, 169, 55, 55);
btnTan.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("tan");
operations ="tan" ;
equalsAlreadyPressed = false;
}
});
btnTan.setFont(new Font("STXinwei", Font.BOLD, 13));
btnTan.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnTan);
JButton btncsc = new JButton("csc");
btncsc.setBounds(230, 169, 55, 55);
btncsc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("csc");
operations ="csc" ;
equalsAlreadyPressed = false;
}
});
btncsc.setFont(new Font("STXinwei", Font.BOLD, 13));
btncsc.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btncsc);
JButton btnsec = new JButton("sec");
btnsec.setBounds(295, 169, 55, 55);
btnsec.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("sec");
operations ="sec" ;
equalsAlreadyPressed = false;
}
});
btnsec.setFont(new Font("STXinwei", Font.BOLD, 13));
btnsec.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnsec);
JButton btnCot = new JButton("cot");
btnCot.setBounds(360, 169, 55, 55);
btnCot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("cot");
operations ="cot" ;
equalsAlreadyPressed = false;
}
});
btnCot.setFont(new Font("STXinwei", Font.BOLD, 13));
btnCot.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnCot);
JButton btnArcsin = new JButton("asin");
btnArcsin.setBounds(35, 110, 75, 43);
btnArcsin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("arcsin");
operations ="arcsin" ;
equalsAlreadyPressed = false;
}
});
btnArcsin.setFont(new Font("STXinwei", Font.BOLD, 12));
btnArcsin.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnArcsin);
JButton btnArccos = new JButton("acos");
btnArccos.setBounds(122, 110, 75, 43);
btnArccos.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("arccos");
operations ="arccos" ;
equalsAlreadyPressed = false;
}
});
btnArccos.setFont(new Font("STXinwei", Font.BOLD, 12));
btnArccos.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnArccos);
JButton btnArctan = new JButton("atan");
btnArctan.setBounds(210, 110, 75, 43);
btnArctan.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("arctan");
operations ="arctan" ;
equalsAlreadyPressed = false;
}
});
btnArctan.setFont(new Font("STXinwei", Font.BOLD, 12));
btnArctan.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnArctan);
JButton btnpower = new JButton("a^b");
btnpower.setBounds(230, 242, 55, 55);
btnpower.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("^");
operations ="^" ;
equalsAlreadyPressed = false;
}
});
btnpower.setFont(new Font("Sylfaen", Font.BOLD, 10));
btnpower.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnpower);
JButton btnAbs = new JButton("abs");
btnAbs.setBounds(295, 110, 55, 43);
btnAbs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("abs");
operations ="abs" ;
equalsAlreadyPressed = false;
}
});
btnAbs.setFont(new Font("Tahoma", Font.BOLD, 11));
btnAbs.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnAbs);
JButton btnaddition = new JButton("+");
btnaddition.setBounds(230, 372, 55, 55);
btnaddition.setFont(new Font("Tahoma", Font.BOLD, 16));
btnaddition.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("+");
operations ="+" ;
equalsAlreadyPressed = false;
}
});
btnaddition.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnaddition);
JButton btnmultiplication = new JButton("\u00D7");
btnmultiplication.setBounds(230, 306, 55, 55);
btnmultiplication.setFont(new Font("Tahoma", Font.BOLD, 16));
btnmultiplication.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("×");
operations ="×" ;
equalsAlreadyPressed = false;
}
});
btnmultiplication.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnmultiplication);
JButton btndelete = new JButton("DEL");
btndelete.setBounds(295, 438, 55, 55);
btndelete.setForeground(new Color(255, 255, 255));
btndelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!"".equals(sBuilder.toString())) {
sBuilder.deleteCharAt(sBuilder.length() - 1);
lblNewLabel.setText(sBuilder.toString());
}
}
});
btndelete.setFont(new Font("STXinwei", Font.BOLD, 10));
btndelete.setBackground(SystemColor.textInactiveText);
frame.getContentPane().add(btndelete);
JButton btnDot = new JButton(".");
btnDot.setBounds(360, 372, 55, 55);
btnDot.setFont(new Font("Tahoma", Font.BOLD, 16));
btnDot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder.append(".");
lblNewLabel.setText(sBuilder.toString());
}
});
btnDot.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnDot);
JButton btnlog = new JButton("log");
btnlog.setBounds(295, 242, 55, 55);
btnlog.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("log");
operations ="log" ;
equalsAlreadyPressed = false;
}
});
btnlog.setFont(new Font("Tahoma", Font.BOLD, 10));
btnlog.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnlog);
JButton btnsubstraction = new JButton("-");
btnsubstraction.setBounds(295, 372, 55, 55);
btnsubstraction.setFont(new Font("Tahoma", Font.BOLD, 16));
btnsubstraction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("-");
operations ="-" ;
equalsAlreadyPressed = false;
}
});
btnsubstraction.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnsubstraction);
JButton btndivision = new JButton("\u00F7");
btndivision.setBounds(295, 306, 55, 55);
btndivision.setFont(new Font("Tahoma", Font.BOLD, 16));
btndivision.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("÷");
operations = "÷";
equalsAlreadyPressed = false;
}
});
btndivision.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btndivision);
JButton btnfactorial = new JButton("!");
btnfactorial.setBounds(360, 240, 55, 55);
btnfactorial.setFont(new Font("Tahoma", Font.BOLD, 16));
btnfactorial.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("!");
operations ="!" ;
equalsAlreadyPressed = false;
}
});
btnfactorial.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnfactorial);
JButton btnAc = new JButton("AC");
btnAc.setBounds(360, 439, 55, 55);
btnAc.setForeground(SystemColor.text);
btnAc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sBuilder = new StringBuilder();
lblNewLabel.setText(null);
equalsAlreadyPressed = false;
}
});
btnAc.setFont(new Font("Tahoma", Font.BOLD, 12));
btnAc.setBackground(SystemColor.textInactiveText);
frame.getContentPane().add(btnAc);
JButton btnmode = new JButton("%");
btnmode.setBounds(360, 306, 55, 55);
btnmode.setFont(new Font("Tahoma", Font.BOLD, 15));
btnmode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
firstnum = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
lblNewLabel.setText("%");
operations ="%" ;
equalsAlreadyPressed = false;
}
});
btnmode.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnmode);
JButton btnequal = new JButton("=");
btnequal.setBounds(230, 438, 55, 55);
btnequal.setFont(new Font("Tahoma", Font.BOLD, 16));
btnequal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((operations=="+")||(operations=="-")||(operations=="×")||(operations=="÷")||(operations=="log")||(operations=="^")||(operations=="%")) {
secondnum = Double.parseDouble(sBuilder.toString());
if(!equalsAlreadyPressed) {
if (operations=="+"&&!equalsAlreadyPressed) {
result = firstnum + secondnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
} else if (operations=="-" && !equalsAlreadyPressed) {
result = firstnum -secondnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
} else if (operations=="×" && !equalsAlreadyPressed) {
result = firstnum * secondnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
} else if (operations=="÷" && !equalsAlreadyPressed) {
equalsAlreadyPressed = true;
if(!(secondnum==0) ) { //if the second number is not 0
result= firstnum/ secondnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(result);
}
else {
lblNewLabel.setText("Math Error");
}
}else if(operations=="^" && !equalsAlreadyPressed){
result = Math.pow(firstnum, secondnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else if (operations=="%" && !equalsAlreadyPressed) {
result = firstnum % secondnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
} else if (operations=="log" && !equalsAlreadyPressed) {
if((firstnum>0)&&(firstnum!=1)&&(secondnum>0)) {
result= Math.log(secondnum)/(Math.log(firstnum));
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(result);
equalsAlreadyPressed = true;
}else{
lblNewLabel.setText("Math Error");
}
}else {
lblNewLabel.setText(sBuilder.toString());
}
}else {
lblNewLabel.setText("Syntax Error");
}
}else if (operations=="!") {
if(!equalsAlreadyPressed) {
if (firstnum<0) {
lblNewLabel.setText("Math Error");
}
else if(firstnum==0) {
result = 1;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
}
else if (firstnum>0) {
int testfactorial = (int)firstnum;
if((testfactorial/firstnum)==1) {
for(int i =1;i<=firstnum;i++) {
product=product*i;
}
result = product;
answer= String.format("%.0f", result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
else {
lblNewLabel.setText("Math Error");
}
}
}else {
lblNewLabel.setText("Syntax Error");
}
}else if ((operations=="sin")||(operations=="cos")||(operations=="tan")||(operations=="csc")||(operations=="sec")||(operations=="cot")||(operations=="abs")||(operations=="arcsin")||(operations=="arccos")||(operations=="arctan")) {
if (operations=="sin"&&!equalsAlreadyPressed) {
result = Math.sin(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else if(operations=="cos"&&!equalsAlreadyPressed) {
result = Math.cos(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else if(operations=="tan"&&!equalsAlreadyPressed) {
double testtan= (firstnum-((Math.PI)/2))/(Math.PI);
int testtanint= (int)testtan;
if(testtanint/testtan==1) {
lblNewLabel.setText("Math Error");
}else {
result = Math.tan(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
}else if(operations=="csc"&&!equalsAlreadyPressed) {
double testcsc=(firstnum/(Math.PI));
int testcscint=(int)testcsc;
if(testcscint/testcsc==1) {
lblNewLabel.setText("Math Error");
}else {
result = 1/(Math.sin(firstnum));
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
}else if(operations=="sec"&&!equalsAlreadyPressed) {
double testsec= (firstnum-((Math.PI)/2))/(Math.PI);
int testsecint= (int)testsec;
if(testsecint/testsec==1) {
lblNewLabel.setText("Math Error");
}else {
result = 1/(Math.cos(firstnum)) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
}else if(operations=="cot"&&!equalsAlreadyPressed) {
double testcot= (firstnum)/(Math.PI);
int testcotint= (int)testcot;
if(testcotint/testcot==1) {
lblNewLabel.setText("Math Error");
}else {
result = 1/(Math.tan(firstnum)) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
}else if(operations=="arcsin"&&!equalsAlreadyPressed) {
if(firstnum>=(-1)&&firstnum<=(1)) {
result =Math.asin(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else {
lblNewLabel.setText("Math Error");
}
}else if(operations=="arccos"&&!equalsAlreadyPressed) {
if(firstnum>=(-1)&&firstnum<=(1)) {
result = Math.acos(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else {
lblNewLabel.setText("Math Error");
}
}else if(operations=="arctan"&&!equalsAlreadyPressed) {
result = Math.atan(firstnum) ;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else if(operations=="abs"&&!equalsAlreadyPressed) {
if(firstnum>=0) {
result = firstnum;
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}else {
result = firstnum*(-1);
answer= String.valueOf(result);
lblNewLabel.setText(answer.toString());
sBuilder = new StringBuilder();
sBuilder.append(answer);
equalsAlreadyPressed = true;
}
}
}
}
});
btnequal.setBackground(SystemColor.inactiveCaption);
frame.getContentPane().add(btnequal);
}
}