hey,
i cant set the size of a frame to a particular dimension.My code is :-
public class ImageShow extends JFrame{
ResultSet r;
Image img;
public ImageShow() throws SQLException
{
setTitle("Image retrieved");
JPanel panel = new JPanel();
//setSize(500, 500);
setDefaultCloseOperation(HIDE_ON_CLOSE);
Container pane = getContentPane();
panel.setLayout(new GridLayout(3,3));
r=ImageRetrieve.rs;
while (r.next())
{
byte[] imagedata = r.getBytes("image_path") ;
img = Toolkit.getDefaultToolkit().createImage(imagedata);
img = img.getScaledInstance(200,200,Image.SCALE_SMOOTH);
ImageIcon icon =new ImageIcon(img);
JLabel Photo = new JLabel(icon) ;
panel.add(Photo) ;
this.pack();
}
JScrollPane scrollpane = new JScrollPane(panel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
pane.add(scrollpane);
this.setPreferredSize(new Dimension(500,500));
this.setVisible(true);
}
}
here i've retrieved the images stored in a database and tried to display it in a gridLayout.But after adding the scrollbar,when i run the above code the new frame appers as very small,and i have to manually stretch it to a convenient size...but all other things are working well...now i just want to display the frame with specified size...is there any problem with the code??
thanks in advance :)