@Override
	public void onUpdate() {

		JButton button = mModel.getPressedButton();
		Dimension size = button.getSize();

		int labelX = mLabel.getX();
		int labelY = mLabel.getY();
		int buttonX = button.getX();
		int buttonY = button.getY();
		int buttonPosX = buttonX / size.width;
		int buttonPosY = buttonY / size.height;
		int buttonIndex = mModel.getPos(buttonPosY, buttonPosX);
		int man;

		if (labelX == buttonX && (labelY - buttonY) == size.height) {

			mModel.updateScore();
			updateTime();

			int labelIndex = buttonIndex + 3;

			mCenterPanel.remove(buttonIndex);
			mCenterPanel.add(mLabel, buttonIndex);
			mCenterPanel.add(button, labelIndex);
			mCenterPanel.validate();

			man = order[labelIndex];
			order[labelIndex] = order[buttonIndex];
			order[buttonIndex] = man;
			

		}

		if (labelX == buttonX && (labelY - buttonY) == -size.height) {

			mModel.updateScore();
			updateTime();

			int labelIndex = buttonIndex - 3;
			mCenterPanel.remove(labelIndex);
			mCenterPanel.add(button, labelIndex);
			mCenterPanel.add(mLabel, buttonIndex);
			mCenterPanel.validate();

			man = order[labelIndex];
			order[labelIndex] = order[buttonIndex];
			order[buttonIndex] = man;
			

		}

		if (labelY == buttonY && (labelX - buttonX) == size.width) {

			mModel.updateScore();
			updateTime();

			int labelIndex = buttonIndex + 1;

			mCenterPanel.remove(buttonIndex);
			mCenterPanel.add(mLabel, buttonIndex);
			mCenterPanel.add(button, labelIndex);
			mCenterPanel.validate();

			man = order[labelIndex];
			order[labelIndex] = order[buttonIndex];
			order[buttonIndex] = man;


		}

		if (labelY == buttonY && (labelX - buttonX) == -size.width) {

			mModel.updateScore();
			updateTime();

			int labelIndex = buttonIndex - 1;

			mCenterPanel.remove(buttonIndex);
			mCenterPanel.add(mLabel, labelIndex);
			mCenterPanel.add(button, labelIndex);
			mCenterPanel.validate();

			man = order[labelIndex];
			order[labelIndex] = order[buttonIndex];
			order[buttonIndex] = man;
			


		}

        mModel.printOrder(order);
        if (mModel.checkPuzzle(order) == 1)
        {

            JFrame winFrame=new JFrame("Congratulation Window!!!");
            winFrame.setSize(480, 288);
            winFrame.setLocationRelativeTo(null);



            Image winImg = mModel.getmWinImg();
            ImageIcon winImageIcon = new ImageIcon(winImg);

            JLabel labelWinImg = new JLabel();
            labelWinImg.setIcon(winImageIcon);
            winFrame.add(labelWinImg);

            winFrame.setVisible(true);

        }


    }