Created
February 21, 2012 15:23
-
-
Save ptitfred/1877009 to your computer and use it in GitHub Desktop.
Draw some BufferedImage in a 'GridLayout'ed JPanel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Display extends JPanel { | |
public Display(BufferedImage[] images) { | |
super(new GridLayout(0, 3)); | |
for (BufferedImage im : images) { | |
add(new Drawer(im)); | |
} | |
} | |
} | |
class Drawer extends JComponent { | |
final BufferedImage img; | |
Drawer(BufferedImage img) { | |
this.img = img; | |
} | |
protected void paintComponent(Graphics g) { | |
g.drawImage(img, 0, 0, new ImageObserver()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment