Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loading Images from a website taking forever.

Posted on 2004-09-06
12
Medium Priority
?
151 Views
Last Modified: 2010-03-31
Hi there, I have a list of images I am loading from a website, these images are all around 5kb each.  When I perform a load, it seems like it takes seconds to load each image.  How can I load them properly so it will load faster?  This is basically what I am doing now.  I am populating a JList with icons and text.  The mFilename_ac variable looks like "http://www.website/picture/picture.gif".  So how can I ensure the picture loads, and that it loads fast?  I have put it in a thread, but it takes 60 seconds to load 100 images on a highspeed dsl?  Thanks experts.

            DefaultListModel dlm2 = new DefaultListModel();
            URL image = new URL(mEmoticonData_t[i].mFileName_ac.toString());
            ImageIcon myIcon_t = new ImageIcon(image);
            for (int i=0; i< numImages_i; i++)
            {
                    dlm2.addElement(new ListEntry(mEmoticonData_t[i].mCharacters_ac.toString(), myIcon_t));
            }
            emoticonList.setModel(dlm2);
0
Comment
Question by:kesea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11993918
> it seems like it takes seconds to load each image.

>  I have put it in a thread, but it takes 60 seconds to load 100 images

The second statement seems to suggest its more like 0.5 sec per image.

Can't see anything in the code that would cause it to be unnecessarily slow.
0
 
LVL 92

Expert Comment

by:objects
ID: 11993927
If you don't use an ImageIcon and instead load your images directly (as Image's) then they will load asynchronously.
0
 

Author Comment

by:kesea
ID: 11996859
How do I load an image directly from a URL?  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 35

Expert Comment

by:girionis
ID: 11996912
ImageIcon icon = ImageIcon(new URL("http://www.mysite.com/myimage.jpg"))
Image image = icon.getImage();
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11999341
Make sure it *is* the download that's taking longer than you think it is, and not the rendering, before you try to take remedial action. For that, you'd be better leaving the code as it is (synchronous) first. You can then give objects' suggestion a try later, although it may not improve things and may even slow them down.
0
 

Author Comment

by:kesea
ID: 11999567
Can I load the images from my .jar file or will I have to get it digitally signed?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11999587
Yes - why do you think you'd need to sign it?
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 12000963
> Can I load the images from my .jar file or will I have to get it digitally signed?

Absolutely, use getResource() to get a URL for the image.
No need to sign it.
0
 
LVL 92

Expert Comment

by:objects
ID: 12000974
URL image = getClass().getResource("/images/my.gif");
ImageIcon i = new ImageIcon(image);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12001249
kesea - can you explain why that particular 'answer' merited the entire question points?
0
 
LVL 92

Expert Comment

by:objects
ID: 12001282
> can you explain why that particular 'answer' merited the entire question points?

because it will greatly speed up the loading ???
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12001357
Using getResource will have no effect on the loading speed whatever
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question