How can i display multiple Pictures in a java.awt.Container best?

hi,
I just started with a new Project, it works just like a FileManager.
On entering a directory all the files in it shall be displayed in a scrollable area. Displayed means here a Graphical representation of the file, in case of a picture a small preview version of it.
I put together a javax.swing.JScrollPane with a java.awt.Container and viewport. The Container has a FlowLayout.
Now for every image in a Directory I create a Component-class in witch I overwrote the public void paint(Graphics g) to display a scaled version of the image, this scaled version is created in the Constructor of my Component-class.
this works fine for just a few images, but if i try to open a directory with a lot of pictures it takes a long time at the beginning and sometimes it just kills the application.
so i changed in a way that only when a Component is in view of the visible rectangle of the scroll pane the scaled image will be created, and when the component gets out of view the image is set to null.
now it is running without killing the application, but it takes way too long to scroll now, because the images are loaded all the time.
so i figured i must be doing something wrong, so what is the best way to get small previews for up to a few hundred files and then display them in a scrollable area? (like in Windows Explorer if you activate the miniature preview)
if anyone can give me some hints, that would be great
thanks shirasuresh

This might give you some ideas:
import java.awt.*;
import javax.swing.*;
public abstract class LazyIcon implements Icon {
    private int width;
    private int height;
    private Image image;
    public LazyIcon(int width, int height) {
        this.width = width;
        this.height = height;
    protected abstract Image createImage();
    public int getIconHeight() {
        return width;
    public int getIconWidth() {
        return height;
    public void paintIcon(Component comp, Graphics g,int x, int y) {
        if (image == null)
            image = createImage();
        g.drawImage(image, x, y, comp);
}You could also do this with a custom component class, but I like the JLabel + Icon combination.
Any if you want to get fancy, you could load images in another thread, at low priority, so when the user is just sitting there, your code is preparing the panel for scrolling ;-)
Message was edited by:
BigDaddyLoveHandles

Similar Messages

  • How can I send multiple pictures to the Kodak link (under file & then order prints)? if the photos are not sequential can it be done?

    how can I send multiple pictures to the Kodak link (under file & then order prints)?  if the photos are not sequential can it be done?

    Does the order matter here?Because the photos will be sent for printing. If there is any other reason, can you please cite example.

  • How can I make multiple pictures slowly fade to white in FCP X ?

    I am new to FCP X and I'm creating a picture slideshow.  How can I make multiple pictures slowly fade to white in FCP X ?
    For example, I would like to have 10 pictures all play in 5 seconds, and starting off with the 1st one being little light; 2nd lighter; 3rd lightter; etc., to 10th being completly white screen...
    Can anyone help ?

    Here is what I would do. Add a 5 second white generator solid to your storyline. Add your 10 half second clips as attached clips. Select them all, right click and make a compound clip. Then keyframe the compound clips opacity from 100% t0 0% with one keyframe at the beginning and one at the end. That will give you a linear reduction in opacity over the 5 seconds(10 pics). You can play with the keyframes to get the effect you want if linear isn't doing it.

  • I can't access the menu of my iPad because it is locked by a picture i was manipulating. How can i display that picture?

    I can't access the menu of my iPad because it is locked by a picture i was manipulating. How can i display that picture?

    http://support.apple.com/kb/ht1212

  • How can I display multiple numeric limit test in operator interface

    I am using Teststand 3 and I want to display additional information like the limits and the results in the sequence UI control. Adding new columns to this control is no problem, so it works good with any step type, that has a single result. But how can I display the information of a step that has multiple results ? The rows of the sequence UI control are limited to a single line.
    Regards
    Dirk Schüller-Möller

    Dirk,
    If you want to display several results for a single step, then you will need to either create a new column for each result or have an expression in your column that will format in a single string all the result that you want to display.
    What you can not do is spawn the result of a single step across several rows (only one step per row).
    Best Regards,
    Alejandro del Castillo
    Ni

  • How can I choose multiple pictures, on the iPad, to attach in an email using Mail?

    I can easily choose and attach one picture from Photos to an email in Mail. I cannot seem to figure out how to choose multiple pictures, then attach all of them at once. I even tried using a separate folder to attach but that did not work either. Thanks in advance.

    From the Photos app tap Edit.
    Tap to select up to 5 photos. More and the Mail option is not possible.
    Tap Share.
    Tap Mail.

  • How can i display blob (picture) using jsp

    i can get byte array from oracle database.
    and how can i use byte array to display just like img src = '' in html ?
    thankyou

    You can't. You have to use <img src...> in the HTML. That src can be to a servlet that gets the image data from the DB and writes the image data out, of course. Just set the content type to image/jpeg or image/gif or whatever it is.

  • How can I print multiple pictures on a single sheet?

    Today 3/27/2012 I tried downloading HP software that says it has a new feature that allows printing multiple pictures on a single sheet of photopaper.  The download started and halted at only one square and sat there flashing for hours, meaning it wasn't downloading on my Pavilion desktop computer.  Since it's a new feature (apparently), no wonder no one as yet has asked this question and so I doubt if anyone has the answer.  But, I'll wait to see.

    You are probably going to get help by posting in the iPhoto forum. You can easily locate it by clicking on Apple Support Discussions on the top left of this page then navigating to the iPhoto forums.
    Roger

  • How can I insert multiple pictures into a "diary" document?

    We started traveling in an RV.  I'm keeping several journals but want to put everything into one document.  I'd like to either insert a slide show at each location I write about, or just insert a number of pictures easily!  the first time I selected about 8 pictures and they just laid over each other.  I couldn't figure out if text in front, around, and they all come in the same size, too big.  I'm looking for an easy fix as I have 22 events to write up and insert pictures in.
    Are pages the best way to go? 

    Hi billdeb411,
    Pages is certainly one way to go for creating documents such as you describe. You might want to look at this page for a better idea of its capabilities -
    Apple - Pages for Mac
    http://www.apple.com/mac/pages/
    Another possibility, particularly if you are trying to create a physical book as your end product, would be to use iPhoto. See its product page here -
    Apple - iPhoto for Mac
    http://www.apple.com/mac/iphoto/
    With it you can create a photo book with your computer and have Apple print the book out for you
    Apple - Print Products for Mac
    http://www.apple.com/mac/print-products/
    Have fun creating your diary!
    Best,
    Brett L

  • How can I display multiple column results of a sql query?

    I'm wanting to display the results of a query selecting from multiple columns, but I can't seem to find an item type that will allow this. I've tried LOV, multiselect, display as text and others. Any ideas on how to do this. Here is my basic query:
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    ;

    Hi,
    Do you just wish to display the result of the query? If so, you can simply parse it out in HTML.
    You can then choose if you want to use tables or css.
    Multiple column layout in tables are based on <tr> and <td>.
    <tr> is a table row, where <td> is a column.
    All tags should be closed.
    Example:
    <table>
    <tr>
    <td>col1</td><td>col2</td>
    </tr>
    <tr>
    <td colspan="2">spans over 2 cols</td>
    </tr>
    </table>If you want to do the same in css:
    (Seems this forum removes the styles!):
    float:left; width:50; << first div and 2 div (col 1 and col 2 style)
    float:left;clear:both; width:100%; << clear both, double width (spans over 2)
    <div>
    <div style="float:left; width:50;">col1</div><div style="float:left;width:50%;">col2</div>
    <div style="float:left;clear:both; width=100%;">Spans over 2 cols</div>
    </div>The div might look more complicated, but if you refrain from styling in the tags them selves, you can define different styles in the .css file.
    You need the clear:both to start a new line with the divs that float.
    I usually run a dedicated "new line" div, without content.. (exception beeing the html-entities version of ' ' (& nbsp ; << without the spaces)).
    eg.:
    <div style="cls"> </div>Parsing out the values from the PL SQL you do like so:
    begin
    declare
       cursor c_search is 
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    begin  
    htp.p('<div style="width:80%;">');
    for v_search in c_search loop
    htp.p('<div style="float:left;clear:none;">'||v_search.location_num||'</div>');
    htp.p('<div style="float:left;clear:none;">'||v_search.submission_date||'</div>');
    end loop;
    htp.p('</div>');
      end;
    end;Ps. hope I understood you correctly, also this code is untested.. but I hope it can still help.
    Edited by: Olav Alexander Mjelde on May 12, 2010 9:36 AM

  • How can i upload multiple pictures on facebook using the ipad 2? Because i've tried uploading before but it should be one by one. Please help.

    Thankyou.

    How are you accessing facebook? I do it through Safari and can upload multiple pics. Are you doing that or through the app?

  • How can I delete multiple pictures without having to select them individually?

    I've tried a few different methods suggested in the forums, none of which seem to work. I'd like to delete them directly from my iPhone, but at this point i really dont care how it happens. I tried following step-by-step directions on how to delete them from my General Settings - Usage - Photo & Cameras - Swipe camera roll to delete... but no option to delete comes up. Is there a reason why this wouldn't work?
    Thanks in advance for any guidance.

    One can delete it from one's computer. In the finder go to homeuser, movies, imovie events, delete the footage.
    Then reopen iMovie and see if that helps.
    Hugh

  • How can I delete multiple pictures

    I can not delete pictures that have transfered from my computer several times. I have tried everything I know.

    If it was synced from your computer then it can't be deleted directly on the iPad, you will need remove/de-select it from where you synced it from on your computer and re-sync.
    http://support.apple.com/kb/HT4236

  • How can I display multiple CPUs on my new iMac i7?

    In activity monitor on one of my MBPs, I can see both CPU Usage graphs. But on my new iMac (4 core), I only see one. Is there a way to see all four?

    James Coley wrote:
    That did not work. Any other ideas?
    no. this should work. you can try getting a 3rd party app like istat menu or the istatpro widget but they should all show the same thing as the activity monitor.

  • I have pictures in a folder, how can I display them in name order?

    I have pictures in a folder, how can I display them in name order?

    Welcome to the Apple Community.
    I don't think you can. You might ensure that their creation dates are in order, but I'm not so such that will help. Ordering seems to be a feature limited to use with iPhoto/Aperture.

Maybe you are looking for

  • Report Builder Layout Model Missing

    when I went to edit an existing report in 10g, I found the display of the Layout model is missing. The fields and frames are all visible in the Object Navigator but they just don't show up in the layout screen. Is there an easy way to fix this - or d

  • T.code required for Vendor line item display and Customer line item display

    Hi Gurus, Pl provide me transaction code for "Vendor line item display and " Customer line item display apart from FBL1n for vendor and FBL5n for customers. Kindly advise. Regards, Samar

  • Problem sending emails out...

    Problem sending emails when saved first as a draft. When I go to send the final draft, it disappears, including the draft. Very upsetting, happened many times but not consistently... Help please, any ideas?

  • What causes this

    Hi Just installed Leopard dont know if its the cause, but I get this http://www.everettpainting.biz/screen_shot.tiff in imovie06 and motion now when ever i import a movie or have to render an effect. The clips are from a small digital camera and impo

  • Euro Symbol in Query Designer

    Hi, I want to edit the name of the Keyfigure in Query designer  and replace it with Euro Symbol .How is thispossible Thanks Maya