1

I'm kinda new in programming and I'm trying to learn everything by myself. Currently I'm working on a project to sort all my bills and other stuff. I managed it to updload the bills as PDF files onto a FTP Server. I'm displaying all outgoing money in a JTable and now I'd like to see a Thumbnail of the PDF in the right part of my swing GUI after i selected a table row.

Here is what I was thinking of:

  1. Get the selected row via a clickListener, read the bill number, which is the same number the file is called on the FTP (e.g. Number: "20130012" / File: "20130012.pdf"). Download the file from the FTP and save it somewhere temporary?!
  2. and now I need to display the pdf in my grid layout but how =) ? If it is a picture I could use the Image Icon right? But how do I get the effect with a pdf?

As soon as I click on the thumbnail, I'd like to open up a pdf reader to see the actual file.

Sorry if this is to less information... just let me know if you need further information. I'd really appreciate a few answers =)

Thanks

GeoGecco
  • 437
  • 4
  • 21

1 Answers1

2

Use a ListSelectionListener to determine which JTable row was clicked and fetch its PDF file. If fetch latency is a problem, use SwingWorker. Once you create a thumbnail image of each page in the selected row's PDF, you can display them in a JList as shown here. Display the selected page at full size in your implementation of ListSelectionListener.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Okay that worked so far, but now I'm displaying the Image of the pdf right next to the table. But when I'm trying to click the next bill I'll get a fileNotFoundException because the file is somehow used. I mean im showing it in the gui and when I try to download the next image and overwrite the old one I get that exception. Do I need to produce a temp file or something like that? – GeoGecco Sep 08 '13 at 16:37
  • Not sure; `File#createTempFile()`, which abstracts host OS variations, may be the right choice. – trashgod Sep 08 '13 at 20:18
  • 1
    thanks alot =). It's working now. I download the PDF, create a temp file and copy the PDF within the temp file. do display the pdf im using the temp file. thanks again – GeoGecco Sep 08 '13 at 21:01