I am working on GUI app (simple game), where one of the objects (Let us call it Object A) uses images that I load directly. I am implementing method loading images on game start so that I do not have to reload files every time I reconfigure the game etc. That method loads all necessary images as an array, then another method (BufferedImage[] getImages()
); returns this array. The class of which this method is (Object B, a JPanel), draws Object A, which in turn, was instantiated by Object C (JFrame, which, of course, also instantiates object B).
I want to know if I can access Object B’s getImages()
method directly from the Object A’s method without passing a reference via method call. Is it entirely possible (via ClassPath etc.), and would it be good programming practise to do so?