It probably imported the same BackgroundPanel class in both cases. You thought that you were using package2.BackgroundPanel but in fact you were using package1.BackgroundPanel. Since both classes are actually similar you didn't notice.
And that brings me to another issue. The classes are too similar to warrant two classes. Why not use one class with all the major code:
And if you want to shield the resource name from the calling class, subclass the panel:
As you see, you now only create such simple subclasses and leave the hard work to one single parent class.
Now, there is one more issue I have with this code. You use an int[] to store the size of the image. That leaves one potential danger (apart from it being null) - the size can be incorrect. I would use a
java.awt.Dimension object instead:
Now you know that the object will always have space for the width and height, and it has easier ways to retrieve them as well - using the named fields instead of anonymous array indexes.