Skip to content

Instantly share code, notes, and snippets.

@ptitfred
Created February 21, 2012 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptitfred/1877009 to your computer and use it in GitHub Desktop.
Save ptitfred/1877009 to your computer and use it in GitHub Desktop.
Draw some BufferedImage in a 'GridLayout'ed JPanel
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