daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Apr 15th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package AddingMachine;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. public class AddControl implements ActionListener {
  7.     private AddView view;
  8.     private AddModel model;
  9.  
  10.     public AddControl(AddView v, AddModel m){
  11.         view=v;
  12.         model=m;
  13.         view.getSumButton().addActionListener(this);
  14.     }
  15.  
  16.     @Override
  17.     public void actionPerformed(ActionEvent actionEvent) {
  18.         if(actionEvent.getSource()==view.getSumButton()){
  19.             getDataFromFields();
  20.             model.sumNumbers();
  21.             view.getResultLabel().setText("="+model.getResult());
  22.         }
  23.     }
  24.  
  25.     public void getDataFromFields(){
  26.         model.setOperand1(Integer.parseInt(view.getOp1Field().getText()));
  27.         model.setOperand2(Integer.parseInt(view.getOp2Field().getText()));
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top