Results 1 to 4 of 4
- 11-10-2009, 09:12 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 1
- Rep Power
- 0
How to update the large amount of thumbnail images in background process
in my application i want to load large number of thumbnail images(each images set as icon for separate jradiobutton) into panel. This panel is in left side of JSplitPane.
when application is starting, now I’m loading the thumbnail buttons without image(to run the application quickly).
now i want to update the buttons with real thumbnail images in background. i tried with thread and SwingUtilities.invokeLater ,but it stuck the application until updating finish.
Note:im using java1.4 (not in the possession to use other versions)
Can anybody give suggestion?
Main GUI
Thread classJava Code:private void buildGUI(File selectedFile) { configButtonPanel(); configThumbnailPanel(selectedFile);//loading with out thumbnail image new TestThread(selectedFile).run(); }
Java Code:import javax.media.jai.NullOpImage; import javax.media.jai.OpImage; import com.sun.media.jai.codec.ImageCodec; import com.sun.media.jai.codec.ImageDecoder; import com.sun.media.jai.codec.TIFFDecodeParam; public class TestThread extends Thread { File tiffImg; TestThread(File img) { this.tiffImg = img; } /* * extracting form tiff images and creates thumbnail then add into vector * */ public void run() { ImageDecoder dec = null; Vector thumImagesV = new Vector(); TIFFDecodeParam param = new TIFFDecodeParam(); param.setDecodePaletteAsShorts(true); param.setJPEGDecompressYCbCrToRGB(true); try { dec = ImageCodec.createImageDecoder("tiff", tiffImg, param); int start, end = 0; for (int i = 0; i < dec.getNumPages(); i++) { RenderedImage rm = new NullOpImage(dec.decodeAsRenderedImage(i), null, OpImage.OP_IO_BOUND, null); thumImagesV.add(i, ImageHandler.createThumbnail(rm, 150)); } } catch (Exception e) { e.printStackTrace(); } } }
-
1) In general you should avoid extending Thread but instead implement Runnable.
2) If you start a new Thread by calling run() it doesn't run as a background thread. Instead you must call start().
- 11-10-2009, 05:19 PM #3
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
-
Similar Threads
-
Draw Large Images
By Sreekanth.m in forum Java 2DReplies: 1Last Post: 09-08-2009, 04:53 PM -
Loading large images in JavaME
By b12 in forum Advanced JavaReplies: 1Last Post: 04-01-2009, 11:02 AM -
Constructor with unknown amount of objects?
By Bernard Robitaille in forum New To JavaReplies: 5Last Post: 03-01-2009, 05:00 AM -
Random Div Background Images
By mchapple in forum New To JavaReplies: 2Last Post: 01-26-2009, 01:16 AM -
Displaying large images
By pir8ped in forum AWT / SwingReplies: 2Last Post: 01-21-2009, 09:20 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks