public static void displayImage(int[]image) { JFrame window = new JFrame("foo"); int width = 28; int height = 28; window.setSize((width+2)*16, (height+2)*16 + 20); PixelGrid pGrid = drawImage(image, width, height); window.add(pGrid); window.setVisible(true); window.repaint(); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static PixelGrid drawImage(int[] image, int width, int height) { PixelGrid grid = new PixelGrid(width, height); int c = 0; for(int i = 0; i<28; i++) { for(int j = 0; j<28; j++) { grid.setPixel(image[c++],j,i); } } return grid; }