Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/09/2014, 11:47
marcusaurelio
 
Fecha de Ingreso: enero-2007
Mensajes: 285
Antigüedad: 17 años, 3 meses
Puntos: 21
Respuesta: libreria pdf-renderer dentro de un jpanel

GENTE.. COMO VA?

bueno .. por el momento lo resolvi.. por medio de un hilo.. y con un sleep antes de mostrar la hora.. si alguien tiene una mejor opcion.. leo sugerencias..

Código:
private void setup() {

   Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    PagePanel panel = new PagePanel();



                   add(panel);
                   panel.repaint();
                   panel.validate();



                   //load a pdf from a byte buffer
                   File file = new File(pdfFile);
                   RandomAccessFile raf = new RandomAccessFile(file, "r");
                   FileChannel channel = raf.getChannel();
                   ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
                   PDFFile pdffile = new PDFFile(buf);

                   // show the first page
                    PDFPage page = pdffile.getPage(0);

                    Thread.sleep(100);
     

                   panel.showPage(page);
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(vistaPrevia2.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(vistaPrevia2.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InterruptedException ex) {
                    Logger.getLogger(vistaPrevia2.class.getName()).log(Level.SEVERE, null, ex);
                }

  }
        });
        thread.start();

    }