Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!TF1.getText().contains(".")) // if the text dont contain .
- {
- if(TF1.getText().equals(0)&& !butt.getText().equals("."))
- {
- //if the jtext contain only 0 clear the text
- // and the button pressed is not '.'
- TF1.setText(butt.getText());
- isOprClick=false;
- }
- else
- {
- TF1.setText(TF1.getText()+butt.getText());
- }
- }
- else if (!butt.getText().equals("."))
- {
- TF1.setText(TF1.getText()+butt.getText());
- isOprClick=false;
- }
- }
- else // if the button is an opr -+*/=
- {
- if(operclickcount==0) //if an operation is clicked for the first time
- {
- operclickcount++;
- //convert the textfield to float and set in n1
- n1=Float.valueOf(TF1.getText());
- opr=butt.getText();
- isOprClick=true;
- } else
- {
- if (!butt.getText().equals("=")) //if the operation is not "="
- {
- if(! isEqualsClick)
- {
- n2=Float.valueOf(TF1.getText());
- TF1.setText(Float.toString(calc(opr, n1, n2)));
- opr=butt.getText();
- n2=Float.valueOf(TF1.getText());
- isOprClick=true;
- isEqualsClick=false;
- } else
- {
- isEqualsClick=false;
- opr=butt.getText();
- }
- }
- else
- {
- n2= Float.valueOf(TF1.getText());
- TF1.setText(Float.toString(calc(opr, n1, n2)));
- n1= Float.valueOf(TF1.getText());
- isOprClick=true;
- isEqualsClick=true;
- }
- }
- }
- };
- return acLis ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement