Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AddingMachine;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class AddControl implements ActionListener {
- private AddView view;
- private AddModel model;
- public AddControl(AddView v, AddModel m){
- view=v;
- model=m;
- view.getSumButton().addActionListener(this);
- }
- @Override
- public void actionPerformed(ActionEvent actionEvent) {
- if(actionEvent.getSource()==view.getSumButton()){
- getDataFromFields();
- model.sumNumbers();
- view.getResultLabel().setText("="+model.getResult());
- }
- }
- public void getDataFromFields(){
- model.setOperand1(Integer.parseInt(view.getOp1Field().getText()));
- model.setOperand2(Integer.parseInt(view.getOp2Field().getText()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement