hey,
i have stored a few images in mySQL database as BLOB.Now i want to retrieve and display the images on frame as a gallery/grid view.I have displayed one image in a frame but when i tried to add more images it fails...Can anyone help with sample code,coz im new to the language....
I've tried the following code,bt it didnt worked:-
public class ImageShow extends JFrame{
Image image;
public int x = 30,y=30;
ResultSet r;
public ImageShow(){
setTitle("Image Retrieved");
setSize(1000,1000);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
setVisible(false);
}
});
setVisible(true);
}
public void paint(Graphics g){
try {
r = ImageRetrieve.rs;
while (r.next())
{
byte[] imagedata = r.getBytes("image_path") ;
image = Toolkit.getDefaultToolkit().createImage(imagedata);
//Toolkit tool = Toolkit.getDefaultToolkit();
g.drawImage(image,x,y,this);
x+=30;
y+=30;
}
}
catch (SQLException ex) {
Logger.getLogger(ImageShow.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Is there any better way?