public void resizeDimension(Cell dragObject) {
        int maxX = 0, maxY = 0;

        Cell curCell;
        for (int i = cells.size() - 1; i >= 0; i--) {
            curCell = cells.get(i);
            maxX = maxX > curCell.getEndX() ? maxX : curCell.getEndX();
            maxY = maxY > curCell.getEndY() ? maxY : curCell.getEndY();
        }

        if (dragObject != null) {
            maxX = maxX > dragObject.getEndX() ? maxX : dragObject.getEndX();
            maxY = maxY > dragObject.getEndY() ? maxY : dragObject.getEndY();
        }

        this.setPreferredSize(new Dimension(maxX, maxY));

        if (this.getParent() != null) {
            this.getParent().validate();
        }

    }