private void resizeScreenIfNeeded() {
        TerminalSize newSize;
        synchronized(resizeQueue) {
            if(resizeQueue.isEmpty())
                return;

            newSize = resizeQueue.getLast();
            resizeQueue.clear();
        }

        int height = newSize.getRows();
        int width = newSize.getColumns();
        ScreenCharacter [][]newBackBuffer = new ScreenCharacter[height][width];
        ScreenCharacter [][]newVisibleScreen = new ScreenCharacter[height][width];
        ScreenCharacter newAreaCharacter = new ScreenCharacter('X', Terminal.Color.GREEN, Terminal.Color.BLACK);
        for(int y = 0; y < height; y++)
        {
            for(int x = 0; x < width; x++)
            {
                if(backbuffer.length > 0 && x < backbuffer[0].length && y < backbuffer.length)
                    newBackBuffer[y][x] = backbuffer[y][x];
                else
                    newBackBuffer[y][x] = new ScreenCharacter(newAreaCharacter);

                if(visibleScreen.length > 0 && x < visibleScreen[0].length && y < visibleScreen.length)
                    newVisibleScreen[y][x] = visibleScreen[y][x];
                else
                    newVisibleScreen[y][x] = new ScreenCharacter(newAreaCharacter);
            }
        }

        backbuffer = newBackBuffer;
        visibleScreen = newVisibleScreen;
        wholeScreenInvalid = true;
        terminalSize = new TerminalSize(newSize);
    }