nidheeshkumar.r 0 Newbie Poster


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);
        Container pane = getContentPane();
        panel.setLayout(new GridLayout(3,3));;
        while (
                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) ;                
        JScrollPane scrollpane = new JScrollPane(panel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        this.setPreferredSize(new Dimension(500,500));

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 i just want to display the frame with specified there any problem with the code??
thanks in advance :)