Java Swing question! Help resizing image into JLabel.?

Well its a pretty simple program. Im just adding a photo to a JLabel and adding that to the GridLayout.
I have 53 pics so the GridLayout is set to (9, 6). The photo's all show up, but it seems they are somewhat too large and therefore they show up congested and overlapping.
Is there a way to resize the image or JLabel or am i doing something wrong.
Thanks

Here is the code for that bit if you didnt get that. This is basically the whole program.

public void makeFrame(){
JFrame frame = new JFrame("Shuffle Cards");
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(9, 6));

for (int i = 0; i < 54 ; i++){
// Adds the images
ImageIcon image = new ImageIcon (i+".jpg");
cp.add(new JLabel(image));
}

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 600);
frame.setVisible(true);
}
 
Back
Top