Just John and me in the store or John and I in the store?

Both forms can be correct, depending on their use in a sentence: "John and I in the store were shopping for groceries" but "A policeman saw John and me in the store."