Results 1 to 4 of 4
  1. #1
    Theesh is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default 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
    Java Code:
    	private void buildGUI(File selectedFile) {
    		configButtonPanel();
    		configThumbnailPanel(selectedFile);//loading with out thumbnail image
    		new TestThread(selectedFile).run();
    	}
    Thread class
    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();
    		}
    	}
     
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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().

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Draw Large Images
    By Sreekanth.m in forum Java 2D
    Replies: 1
    Last Post: 09-08-2009, 05:53 PM
  2. Loading large images in JavaME
    By b12 in forum Advanced Java
    Replies: 1
    Last Post: 04-01-2009, 12:02 PM
  3. Constructor with unknown amount of objects?
    By Bernard Robitaille in forum New To Java
    Replies: 5
    Last Post: 03-01-2009, 06:00 AM
  4. Random Div Background Images
    By mchapple in forum New To Java
    Replies: 2
    Last Post: 01-26-2009, 02:16 AM
  5. Displaying large images
    By pir8ped in forum AWT / Swing
    Replies: 2
    Last Post: 01-21-2009, 10:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •