protected void findConnected(boolean[][] selected, int i, int j, ArrayList list) {
        int right = j;
        for (; right < selected[i].length; ++right) {
            if (!selected[i][right]) 
                break;
        }
        right--;
        
        int bottom = i;
        for (; bottom < selected.length; ++bottom) {
            if (!selected[bottom][j]) 
                break;
        }
        bottom--;
        
        for (int k = i+1; k <= bottom; ++k) {
            for (int l = j+1; l <= right; ++l) {
                if (!selected[k][l]) {
                    right = l-1;
                }
            }
        }
        
        for (int k = i; k <= bottom; ++k) {
            for (int l = j; l <= right; ++l) {
                selected[k][l] = false;
            }
        }
        Rectangle r = new Rectangle(j, i, right, bottom);
        list.add(r);
    }