I am trying to get 20 images displayed on a jframe in jlabels using a gridlayout. I have added a while loop but still i am only am to see 1 image, please can you help me to display more than image in jlabels on a jframe?
setSize(600, 600);
setDefaultCloseOperation(HIDE_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new GridLayout(4,4));
connection = getConnection();
try { // table name:image and second image is field name
statement = (PreparedStatement) connection
.prepareStatement("select content from images");
result = statement.executeQuery();
byte[] image = null;
while (result.next()) {
image = result.getBytes("image");
}
Image img = Toolkit.getDefaultToolkit().createImage(image);
img = img.getScaledInstance(100, 200, Image.SCALE_SMOOTH);
ImageIcon icon = new ImageIcon(img);
JLabel lPhoto = new JLabel();
lPhoto.setIcon(icon);