Tiles

There is an image file containing a set of small pictures. How do I display one of these small pictures (into a JFrame) if the coordinates relative to the upper left corner are known?


        JFrame f = new JFrame("Load Image Sample");
            
        f.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        f.add(new LoadSmallPicture());   <==
        f.pack();
        f.setVisible(true);

I recommend creating a map or array of BufferedImages that are created from the different portions of your sprite sheet. This way you don’t have to load the entire sheet all at once, but you still get the cheaper hard disk memory cost of the sprite sheet.