473,769 Members | 5,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

applet loading of images -- network or JAR approach faster?

1 New Member
hi all,

i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and incurred a network hit per image file.

i wanted to avoid the overhead of a separate network connection for each image file, so i bundled all the images into the JAR file. yet, somehow, the loading time for the applet is slower now! i'm totally mystified.

i put the code for loading each image into a separate thread as well. here's the thread code:

Expand|Select|Wrap|Line Numbers
  1. public class ImageLoaderThread extends Thread {
  2.  
  3.     private Hashtable images;
  4.     private DesignApplet applet;
  5.  
  6.     public ImageLoaderThread(DesignApplet applet, Hashtable images, String imageFile) {
  7.         super(imageFile);
  8.         this.images = images;
  9.         this.applet = applet;
  10.     }
  11.  
  12.     public void run() {
  13.         try {
  14.  
  15.             System.out.println("Starting to load image ...");
  16.  
  17.             String imageFile = getName();
  18.             InputStream is = applet.getClass().getResourceAsStream(imageFile);
  19.             int arraySize = is.available() * 2; // CH: create extra space just in case
  20.             System.out.println("Image Loader Thread: " + imageFile + "bytes available: " + arraySize);
  21.             BufferedInputStream bis = new BufferedInputStream(is);
  22.             byte[] byBuf = new byte[arraySize];  // a buffer large enough for our image
  23.             int byteRead = bis.read(byBuf, 0, arraySize);
  24.             Image buttonImage = Toolkit.getDefaultToolkit().createImage(byBuf);
  25.             images.put(imageFile, buttonImage);
  26.         }
  27.         catch(Exception e) {
  28.             System.out.println("Exception while loading: " + getName());
  29.             e.printStackTrace();
  30.         }
  31.  
  32.     }
  33.  

imageFile is the name of an image file stored in the JAR file. it's not stored on the server anywhere, so i know the file must be created from the JAR file. despite this, the speed of image creation seems tied to the network. in other words, when i attempt to load the applet over a slow link, it takes longer to load than over a fast link.

any ideas? i'm seriously stumped and could use help. what am i doing wrong? my goals are to minimize loading time of the applet while minimizing network hits for the server.

thanks!

p.s. if you want to play w/ the applet, click on the following link and click the "Customize" button: http://www.cengraving. com/s/z/Photo-plaques/PP024.jsp
Nov 6 '06 #1
0 2203

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8211
by: Don | last post by:
Hi, I try to get a simple applet working, the class-file does load, but the image doesn't appear;( An error doesn't appear. The view is and stays 'grey' What I want: Automatic refresh of a webcam image Filename is the same. File is located in same directory as applet.
2
2524
by: Mark Richards | last post by:
An applet on one of my pages uses a big picture as background. I want to load it before the applet and the rest of the html source. By doing this I want to avoid that the pane of the applet is grey during the load of the picture. How do I do that? Or even better: How can I display something like a progress bar or at least a temporary, self removing message (dialog) "Please wait a few second..." until the picture and the applet were...
4
3747
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just did a preload script. But then the user has to sit for 5 minutes waiting for 63 images to download! My images are about 640x480 and average 100kb. Is this too much for one page to load? Should I load my slideshow into differerent windows? If so,...
8
3393
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if the Java method is called just once and then the page is refreshed. FireFox does not crash at all...
2
2508
by: Lauren Quantrell | last post by:
Is there any speed difference or advantage to loading different types of images from a folder residing on a client machine into an Access Image Control on a form? For example, if I have a folder of .JPGs and a folder of .BMPs each with the same images (stored in the two different formats) will the Image Control load faster with a JPG or a BMP or does it not make a difference? Thaks,
0
2867
by: NoaGross | last post by:
Hi, I'm relly new in java and I have a problem. I'm using java applet. When using http all ok, but when trying to use https i get: Java Plug-in 1.5.0_10 Using JRE version 1.5.0_10 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\noa ---------------------------------------------------- c: clear console window
1
2850
by: brickled | last post by:
hello all, i have used the browser objects (using vb6 and vb.net) in the past to do many things "automatically" on the web. now i'm trying to "interact" with a java applet on a website. I am new to java and java applets. After loading the webpage that contains the applet into a browser object i was able to to make simple calls to the java applet - calls such as .getcodebase and ..getparameter along with a few others. i decompiled the...
0
1486
by: shanmukhi | last post by:
Hi All I got a problem in running java programs. i am not able to run java applet while running i got a problem as Loading Java Applet Failed java.lang.NoClassDefFoundError: App (wrong name: src/App) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source)
0
1480
by: shanmukhi | last post by:
Hi All I got a problem in running java Applet i am not able to run java applet while running i got a problem as Loading Java Applet Failed java.lang.NoClassDefFoundError: App (wrong name: src/App) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source)
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.