private void pause() {
        mIsPaused = true;
        LoopKeyListener pausedKeyListener = new LoopKeyListener(LoopKeyListener.PAUSED);
        removeKeyListener(mPlayer);
        addKeyListener(pausedKeyListener);
        
        setPausedMessage();
        
        mBoard.setVisible(false);
        mSidePanel.setVisible(false);
        mAbilityPanel0.setVisible(false);
        mAbilityPanel1.setVisible(false);
        mAbilityPanel2.setVisible(false);
        mAbilityPanel3.setVisible(false);

        long timePaused = System.currentTimeMillis();
        while (mIsPaused) {
            System.out.print(""); //This fixes a bug and I don't know why. 
        }
        long totalTimePaused = System.currentTimeMillis() - timePaused;
        
        /* Update cooldowns to prevent cheating. */
        if (mBoostUnlocked) {
            mBoostPreviousTime += totalTimePaused;
        }
        if (mLinePieceAbilityUnlocked) {
            mLinePiecePreviousTime += totalTimePaused;
        }
        if (mZeroGravityUnlocked) {
            mZeroGravityPreviousTime += totalTimePaused;
        }
        if (mClearGridUnlocked) {
            mClearGridPreviousTime += totalTimePaused;
        }
        
        removeKeyListener(pausedKeyListener);
        addKeyListener(mPlayer);
        
        mBoard.setVisible(true);
        mSidePanel.setVisible(true);
        mAbilityPanel0.setVisible(true);
        mAbilityPanel1.setVisible(true);
        mAbilityPanel2.setVisible(true);
        mAbilityPanel3.setVisible(true);
    }