How to Load images one by one...
I am sorry friends..I am new to Forums...Sorry if i do any mistakes..
I wanna ask....how could we load images one by one..show them one by one..
My problem is...when load images from a directory...it loads Images ...But for that moment it freezes..and I cant do..any thing..and suddenly it showall images loaded..in JLabel...so please kindly somebody help me..
I am new to java as well...
Thanks in advance...thankyou very much
My code goes here..
This is the code where i am loading my images from directory using FileDialog...
class LoadFile implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==load_btn)
{
String file=getImageFile();
if(file!=null)
{
System.out.println(file);
pre=file;
dir=new File(pre);
ids=dir.list();
int x=0,y=0;
int file_count=ids.length;
try{
img_btn = new JLabel[ids.length];
jpanel3.removeAll();
for(int i=1;i<ids.length;i++)
{
c.insets = new Insets(10, 10, 10, 10);
String img_path=pre + ids[i];
jlabel4.setText(img_path);
jlabel4.
Image img=LoadImage(img_path);
img_btn[i] = new JLabel()
{
public JToolTip createToolTip()
{
return new JMultiLineToolTip();
}
};
try
{
ImageIcon img_icon = new ImageIcon(img.getScaledInstance(-1,100, Image.SCALE_SMOOTH));
//img_icon.setImage(ImageUtils.makeReflectedImage (img_icon.getImage (), 10, 10, 0.1f));
img_btn[i].setOpaque(false);
img_btn[i].setBorder(BorderFactory.createLineBorder(Color.WH ITE,3));
img_btn[i].setIcon(img_icon);
img_btn[i].setToolTipText("File Name:-" +ids[i]+"\nType:- "+extractFileExtension(ids[i])+"\n Size:-" +getReadableFileSize(new File(img_path).length()));
c.gridx=x;
c.gridy=y;
if(i%5==0)
{
x=0;
y=y+30;
}
else
{
x=x+30;
}
jpanel3.add(img_btn[i],c);
img_btn[i].setVisible(true);
scroll.validate();
scroll.repaint();
jpanel3.validate();
jpanel3.repaint();
}
catch(Exception e){}
}
}
catch(ArrayIndexOutOfBoundsException arr)
{
System.out.println("This much Image is displaying only");
}
}
}
}
}