Visualização de Arquivos pelo Java

16 respostas
E

Olá a todos!

Gostaria de saber se existe um jeito de eu visualizar arquivos como (microsoft word, excel, pdf) pelo java, tipo um painel em Swing, estou muito precisando de uma ferramenta que consiga fazer isso.

Estou trabalhando em uma ferramenta GED (Gestão Eletrônica de Documentos) e queria visualizar esses arquivos diretamente, sem ter que abrir outros softwares.

Desde já agradeço a compreesão de todos.

16 Respostas

R

Boa tarde .
Não sei até que ponto isso pode te ajudar:

http://poi.apache.org/index.html

até.

F

essa classe exibe apenas arquivos texto, mas talvez sirva como base pro que você precisa.

import java.awt.*;
import java.io.*;

public class FileViewer extends Frame {

    Button close;

    public FileViewer(String filename) throws IOException {
        super("FileViewer: " + filename);
        File f = new File(filename);
        int size = (int) f.length();
        int bytes_read = 0;
        FileInputStream in = new FileInputStream(f);
        byte[] data = new byte[size];
        while(bytes_read < size)
            bytes_read += in.read(data, bytes_read, size-bytes_read);
        
        TextArea textarea = new TextArea(new String(data, 0), 24, 80);
        textarea.setFont(new Font("Helvetica", Font.PLAIN, 12));
        textarea.setEditable(false);
        this.add("Center", textarea);
        
        close = new Button("Close");
        this.add("South", close);
        this.pack();
        this.show();
    }
    
    public boolean action(Event e, Object what) {
        if (e.target == close) {
            this.hide();
            this.dispose();
            return true;
        }
        return false;
    }
    
    static public void main(String[] args) throws IOException {
        if (args.length != 1) {
            System.out.println("Usage: java FileViewer <filename>");
            System.exit(0);
        }
        try { Frame f = new FileViewer(args[0]); }
        catch (IOException e) { System.out.println(e); }
    }
}
E

Com o Apache POI eu consigo visualizar arquivos do office?

ou me permite apenas alterar?

Vou testar, depois eu posto com o resultado!

Valeu

E

Não consegui não com o Apachi, eles não consegue ler os arquivos do office 2007.

Alguem mais teria um outra sugestão?

K

ellcyo:
Não consegui não com o Apachi, eles não consegue ler os arquivos do office 2007.

Alguem mais teria um outra sugestão?

Lembro-me de ter ouvido falar que a Microsoft liberou as especificações dos arquivos do pacote Office. Acredito que isso facilitará imensamente o surgimento de ferramentas para visualização e manipulação desses formatos de arquivos, já que antes da liberação das especificações tudo tinha que ser feito na base da engenharia reversa.

Se o Apache POI ainda não tem solução pronta para tu visualizar e/ou manipular os arquivos dos office 2007, tu pode esperar ele ter tal solução ou você pode criar tal ferramenta “na mão” já que as especificações foram liberadas.

Inté.

N

Com o POI você consegue apenas editar os arquivos. Se você quer visualizar, pode usar SWT. Com ele você consegue inserir objetos activex na janela da sua aplicação. Não tenho certeza, mas eu acho que dá pra fazer com AWT também, mas não sei como é. Ah, e em ambas as possibilidades vc tem que ter o office e/ou o adobe reader pra poder exibir os arquivos.

http://www.eclipse.org/articles/article.php?file=Article-ActivexSupportInSwt/index.html
http://java.sys-con.com/node/48177

N

Dei umas “googladas” encontrei isso aqui:

https://jdic.dev.java.net/
https://jdic.dev.java.net/documentation/incubator/JDICplus/index.html

Rodei aqui e funcionou na primeira.

:smiley:

E

Valeu mano,

Vou tentar esses exemplos, mais com SWT eu conseguiria usar no NetBeans?

N

Então, esquece o que eu falei de SWT. Dá uma olhada no segundo link que eu passei e roda os exemplos da página. Tem um lá que é exatamente o que vc quer.

:wink:

E

Seguinte mano,

Funcionou blz e é exatamente isso que eu quero, porém, funcionou apenas com o office xp, testei com o Office 2007 e não funcionou!

Mais muito obrigado, e qualquer coisa estamos por aqui!

Valeu!

T

ellcyo:
Seguinte mano,

Funcionou blz e é exatamente isso que eu quero, porém, funcionou apenas com o office xp, testei com o Office 2007 e não funcionou!

Mais muito obrigado, e qualquer coisa estamos por aqui!

Valeu!

talvez porque o office 2007 segue outro padrão… http://en.wikipedia.org/wiki/Office_Open_XML

E

Seguinte,

Estou tentando implementar mais está dando erro.

import org.jdic.web.BrComponent;

/*
 * DocViewFrame.java
 *
 * Created on June 18, 2008, 12:34 PM
 */
import org.jdic.web.event.BrComponentEvent;
import org.jdic.web.event.BrComponentListener;



/**
 *
 * @author  uta
 */
public class DocViewFrame extends javax.swing.JFrame {

    /** Creates new form DocViewFrame */
    public DocViewFrame() {
        BrComponent.DESIGN_MODE = false;
        BrComponent.setDefaultPaintAlgorithm(BrComponent.PAINT_NATIVE);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        tbCommands = new javax.swing.JToolBar();
        btFlashGame = new javax.swing.JButton();
        btVideo = new javax.swing.JButton();
        btPDF = new javax.swing.JButton();
        btDisk = new javax.swing.JButton();
        btMSWord = new javax.swing.JButton();
        btMSExcel = new javax.swing.JButton();
        btMSOutlook = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Document Viewer");
        setName("main"); // NOI18N

        tbCommands.setFloatable(false);
        tbCommands.setRollover(true);
        tbCommands.setMaximumSize(new java.awt.Dimension(10, 20));
        tbCommands.setMinimumSize(new java.awt.Dimension(10, 20));

        btFlashGame.setText("Flash Game");
        btFlashGame.setFocusable(false);
        btFlashGame.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btFlashGame.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btFlashGame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFlashGameActionPerformed(evt);
            }
        });
        tbCommands.add(btFlashGame);

        btVideo.setText("Video");
        btVideo.setFocusable(false);
        btVideo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btVideo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btVideo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btVideoActionPerformed(evt);
            }
        });
        tbCommands.add(btVideo);

        btPDF.setText("PDF Reader");
        btPDF.setFocusable(false);
        btPDF.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btPDF.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btPDF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPDFActionPerformed(evt);
            }
        });
        tbCommands.add(btPDF);

        btDisk.setText("Disk C:");
        btDisk.setFocusable(false);
        btDisk.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btDisk.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btDisk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDiskActionPerformed(evt);
            }
        });
        tbCommands.add(btDisk);

        btMSWord.setText("MS Word");
        btMSWord.setFocusable(false);
        btMSWord.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSWord.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSWord.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSWordActionPerformed(evt);
            }
        });
        tbCommands.add(btMSWord);

        btMSExcel.setText("MS Excel");
        btMSExcel.setFocusable(false);
        btMSExcel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSExcel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSExcel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSExcelActionPerformed(evt);
            }
        });
        tbCommands.add(btMSExcel);

        btMSOutlook.setText("MS Outlook");
        btMSOutlook.setFocusable(false);
        btMSOutlook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSOutlook.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSOutlook.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSOutlookActionPerformed(evt);
            }
        });
        tbCommands.add(btMSOutlook);

        getContentPane().add(tbCommands, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>

private void btVideoActionPerformed(java.awt.event.ActionEvent evt) {                                        
    brView.setURL("");
    brView.addBrComponentListener( new BrComponentListener(){
            public String sync(BrComponentEvent e) {
                if(BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()){
                    brView.setHTML(
"<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" + 
"<object style='margin: 0px 0px 0px 0px; width:100%; height:100%' " +
        "value='http://www.youtube.com/v/mlTKOsBOVMw&hl=en'>" + 
        "<param name='wmode' value='transparent'> " +
        "<embed style='margin: 0px 0px 0px 0px; width:100%; height:100%' src='http://www.youtube.com/v/mlTKOsBOVMw&hl=en' type='application/x-shockwave-flash' wmode='transparent'></embed>" +
"</object></body></html>"                        
                    );    
                    brView.removeBrComponentListener(this);
                }    
                return null;
            }
    });        
}                                       

private void btMSWordActionPerformed(java.awt.event.ActionEvent evt) {                                         
    brView.setURL("http://www.aaopt.org/content/docs/course-abstractFAQs.doc");
}                                        

private void btMSOutlookActionPerformed(java.awt.event.ActionEvent evt) {                                            
    //http://weblogs.asp.net/mnissen/archive/2004/07/05/173364.aspx
    //http://www.outlookcode.com/d/OVCViewDemo.htm
    // typelib filename: OUTLCTL.DLL
    brView.setURL("");
    brView.addBrComponentListener( new BrComponentListener(){
            public String sync(BrComponentEvent e) {
                if(BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()){
                    brView.setHTML(
"<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" + 
      "<object classid='CLSID:0006F063-0000-0000-C000-000000000046' " +
            "id='ViewCtlFolder' " +
            "width='100%' " +
            "height='100%' " +
            "codebase='http://activex.microsoft.com/activex/controls/office/outlctlx.CAB#ver=9,0,0,3203'>"+
       "<param name='Namespace' value='MAPI'>"+
       "<param name='Folder' value='Calendar'>"+
       "<param name='View' value='Day/Week/Month View With AutoPreview'>"+
       "<param name='Restriction' value=''>"+
       "<param name='DeferUpdate' value='0'>"+
"</object></body></html>"                        
                    );    
                    brView.removeBrComponentListener(this);
                }    
                return null;
            }
    });
}                                           

private void btFlashGameActionPerformed(java.awt.event.ActionEvent evt) {                                            
    brView.setURL("");
    brView.addBrComponentListener( new BrComponentListener(){
            public String sync(BrComponentEvent e) {
                if(BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()){
                    brView.setHTML(
"<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" + 
"<object style='margin: 0px 0px 0px 0px; width:100%; height:100%' classid='CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'> " +
"  <param name='movie' value='http://flashportal.ru/monstertruckcurfew.swfi'> " +
"  <param name='quality' value='high'> " +
"  <param name=bgcolor value='#00FF00'>" +
"</object></body></html>"                        
                    );    
                    brView.removeBrComponentListener(this);
                }    
                return null;
            }
    });

}                                           

private void btPDFActionPerformed(java.awt.event.ActionEvent evt) {                                      
    brView.setURL("http://java.sun.com/developer/Books/j2ee/advancedprogramming/jni.pdf");    
}                                     

private void btDiskActionPerformed(java.awt.event.ActionEvent evt) {                                       
    brView.setURL("c:/");
}                                      

private void btMSExcelActionPerformed(java.awt.event.ActionEvent evt) {                                          
    brView.setURL("http://www.seomoz.org/user_files/top-100-domains/SEOmoz-Top-100-Most-Visited-Domains.xls");
}                                         

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DocViewFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton btDisk;
    private javax.swing.JButton btFlashGame;
    private javax.swing.JButton btMSExcel;
    private javax.swing.JButton btMSOutlook;
    private javax.swing.JButton btMSWord;
    private javax.swing.JButton btPDF;
    private javax.swing.JButton btVideo;
    private javax.swing.JToolBar tbCommands;
    // End of variables declaration

}

variável “brView” não tem nenhuma referência, nenhuma declaração.

Alguém pode me ajudar, esse é o arquivo de exemplo que eu estava testando.

E

Senhores,

Solução encontrada pelo meu amigo neófito.

Estou postando o arquivo corrigido pra conhecimento de todos sobre visualização de documentos (*.doc, *.xls, *.swf, *.pdf, videos e etc…) pelo java.

Fonte: http://fisheye5.cenqua.com/browse/jdic/src/incubator/JDICplus/demo/DocViewDemo/src/DocViewFrame.java?r=1.2

Vale lembrar que com essa solução o sistema se torna dependente da plataforma windows, porém, pode-se fazer alguns tratamentos para voltar a se tornar multiplataformas.

import javax.swing.SwingUtilities; 
import org.jdic.web.BrComponent; 
import org.jdic.web.event.BrComponentEvent; 
import org.jdic.web.event.BrComponentListener;

/** 
 * 
 * @author  uta 
 */
public class PView extends javax.swing.JFrame {

    /** Creates new form DocViewFrame */
    public PView() {
        BrComponent.DESIGN_MODE = false;
        BrComponent.setDefaultPaintAlgorithm(BrComponent.PAINT_NATIVE);
        initComponents();
    }

    /** This method is called from within the constructor to 
     * initialize the form. 
     * WARNING: Do NOT modify this code. The content of this method is 
     * always regenerated by the Form Editor. 
     */
    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 
    private void initComponents() {

        brView = new org.jdic.web.BrComponent();
        tbCommands = new javax.swing.JToolBar();
        btFlashGame = new javax.swing.JButton();
        btVideo = new javax.swing.JButton();
        btPDF = new javax.swing.JButton();
        btDisk = new javax.swing.JButton();
        btMSWord = new javax.swing.JButton();
        btMSExcel = new javax.swing.JButton();
        btMSOutlook = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Document Viewer");
        setName("main"); // NOI18N 

        brView.setName("viewer"); // NOI18N 

        javax.swing.GroupLayout brViewLayout = new javax.swing.GroupLayout(brView);
        brView.setLayout(brViewLayout);
        brViewLayout.setHorizontalGroup(
                brViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 397, Short.MAX_VALUE));
        brViewLayout.setVerticalGroup(
                brViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 279, Short.MAX_VALUE));

        getContentPane().add(brView, java.awt.BorderLayout.CENTER);

        tbCommands.setFloatable(false);
        tbCommands.setRollover(true);
        tbCommands.setMaximumSize(new java.awt.Dimension(10, 20));
        tbCommands.setMinimumSize(new java.awt.Dimension(10, 20));

        btFlashGame.setText("Flash Game");
        btFlashGame.setFocusable(false);
        btFlashGame.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btFlashGame.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btFlashGame.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFlashGameActionPerformed(evt);
            }
        });
        tbCommands.add(btFlashGame);

        btVideo.setText("Video");
        btVideo.setFocusable(false);
        btVideo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btVideo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btVideo.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btVideoActionPerformed(evt);
            }
        });
        tbCommands.add(btVideo);

        btPDF.setText("PDF Reader");
        btPDF.setFocusable(false);
        btPDF.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btPDF.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btPDF.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btPDFActionPerformed(evt);
            }
        });
        tbCommands.add(btPDF);

        btDisk.setText("Disk C:");
        btDisk.setFocusable(false);
        btDisk.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btDisk.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btDisk.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDiskActionPerformed(evt);
            }
        });
        tbCommands.add(btDisk);

        btMSWord.setText("MS Word");
        btMSWord.setFocusable(false);
        btMSWord.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSWord.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSWord.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSWordActionPerformed(evt);
            }
        });
        tbCommands.add(btMSWord);

        btMSExcel.setText("MS Excel");
        btMSExcel.setFocusable(false);
        btMSExcel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSExcel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSExcel.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSExcelActionPerformed(evt);
            }
        });
        tbCommands.add(btMSExcel);

        btMSOutlook.setText("MS Outlook");
        btMSOutlook.setFocusable(false);
        btMSOutlook.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btMSOutlook.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btMSOutlook.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btMSOutlookActionPerformed(evt);
            }
        });
        tbCommands.add(btMSOutlook);

        getContentPane().add(tbCommands, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents 

    private void btVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btVideoActionPerformed 
        brView.setURL("");
        brView.addBrComponentListener(new BrComponentListener() {

            public String sync(BrComponentEvent e) {
                if (BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()) {
                    brView.setHTML(
                            "<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" +
                            "<object style='margin: 0px 0px 0px 0px; width:100%; height:100%' " +
                            "value='http://www.youtube.com/v/mlTKOsBOVMw&hl=en'>" +
                            "<param name='wmode' value='transparent'> " +
                            "<embed style='margin: 0px 0px 0px 0px; width:100%; height:100%' src='http://www.youtube.com/v/mlTKOsBOVMw&hl=en' type='application/x-shockwave-flash' wmode='transparent'></embed>" +
                            "</object></body></html>");
                    brView.removeBrComponentListener(this);
                }
                return null;
            }
        });
    }//GEN-LAST:event_btVideoActionPerformed 

    private void btMSWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMSWordActionPerformed 
        brView.setURL("http://www.aaopt.org/content/docs/course-abstractFAQs.doc");
    }//GEN-LAST:event_btMSWordActionPerformed 

    private void btMSOutlookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMSOutlookActionPerformed 
        //http://weblogs.asp.net/mnissen/archive/2004/07/05/173364.aspx 
        //http://www.outlookcode.com/d/OVCViewDemo.htm 
        // typelib filename: OUTLCTL.DLL 
        brView.setURL("");
        brView.addBrComponentListener(new BrComponentListener() {

            public String sync(BrComponentEvent e) {
                if (BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()) {
                    brView.setHTML(
                            "<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" +
                            "<object classid='CLSID:0006F063-0000-0000-C000-000000000046' " +
                            "id='ViewCtlFolder' " +
                            "width='100%' " +
                            "height='100%' " +
                            "codebase='http://activex.microsoft.com/activex/controls/office/outlctlx.CAB#ver=9,0,0,3203'>" +
                            "<param name='Namespace' value='MAPI'>" +
                            "<param name='Folder' value='Calendar'>" +
                            "<param name='View' value='Day/Week/Month View With AutoPreview'>" +
                            "<param name='Restriction' value=''>" +
                            "<param name='DeferUpdate' value='0'>" +
                            "</object></body></html>");
                    brView.removeBrComponentListener(this);
                }
                return null;
            }
        });
    }//GEN-LAST:event_btMSOutlookActionPerformed 

    private void btFlashGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFlashGameActionPerformed 
        brView.setURL("");
        brView.addBrComponentListener(new BrComponentListener() {

            public String sync(BrComponentEvent e) {
                if (BrComponentEvent.DISPID_NAVIGATECOMPLETE2 == e.getID()) {
                    brView.setHTML(
                            "<html><head></head><body style='border:none;margin: 0px 0px 0px 0px;' scroll='no' scrolling='no'>" +
                            "<object style='margin: 0px 0px 0px 0px; width:100%; height:100%' classid='CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'> " +
                            "  <param name='movie' value='http://flashportal.ru/monstertruckcurfew.swfi'> " +
                            "  <param name='quality' value='high'> " +
                            "  <param name=bgcolor value='#00FF00'>" +
                            "</object></body></html>");
                    brView.removeBrComponentListener(this);
                }
                return null;
            }
        });

    }//GEN-LAST:event_btFlashGameActionPerformed 

    private void btPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btPDFActionPerformed 
        //"http://java.sun.com/developer/Books/j2ee/advancedprogramming/jni.pdf");
        brView.setURL("file://c:/temp/arquivo.pdf");
    }//GEN-LAST:event_btPDFActionPerformed 

    private void btDiskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDiskActionPerformed 
        brView.setURL("c:/");
    }//GEN-LAST:event_btDiskActionPerformed 

    private void btMSExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMSExcelActionPerformed 
        brView.setURL("http://www.seomoz.org/user_files/top-100-domains/SEOmoz-Top-100-Most-Visited-Domains.xls");
    }//GEN-LAST:event_btMSExcelActionPerformed 

    /** 
     * @param args the command line arguments 
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PView().setVisible(true);
            }
        });
    }    // Variables declaration - do not modify//GEN-BEGIN:variables 
    private org.jdic.web.BrComponent brView;
    private javax.swing.JButton btDisk;
    private javax.swing.JButton btFlashGame;
    private javax.swing.JButton btMSExcel;
    private javax.swing.JButton btMSOutlook;
    private javax.swing.JButton btMSWord;
    private javax.swing.JButton btPDF;
    private javax.swing.JButton btVideo;
    private javax.swing.JToolBar tbCommands;    // End of variables declaration//GEN-END:variables 
}
B

ai galera, estou reativando este post.

bem, testei o jdic, mas não é o que eu quero, ele depende do office e do adobe para funcionar, então não me serve.

pelo que li nos forum o POI somente permite editar os arquivos, mas não visualizar, (me corrijão se estiver errado).

o que eu estou procurando é um visualizador de documentos, principalmente PDF, que não precise do Adobe instalado na maquina, e FREE logico.

se alguem tiver alguma novidade sobre o assunto, favor dar um retorno

t+

grato pela atenção

E

Olá parceiro, hoje você tem uma solução que uso nos nossos produtos para visualização de PDF que inclusive ele pega direto do banco.
É o IcePdf viewer, muito show a ferramenta, e acima de tudo, é de gratis.

Espero ter ajudado.

G

Ola! Tambem preciso fazer um visualizador de arquivos,mas um pouco mais completo com comandos do teclado, exemplo: teclas Home, End, PgUp, Pgn, seta para baixo,para cima etc.Detalhe!Preciso fazer isso usando os metodos das seguintes classes Class ListaDupla e Class No:

class ListaDupla{
 private No primeiro, ultimo;
// Inserir um elemento no final da lista
public void Inserir(No Linha) {...}
// Exclui todos os elementos da lista
public void Limpar() {...}
public No getPrimeiro(){...}
public No getUltimo(){...}
}
class No{
 private No ant, prox;
private String80 Linha;
public String getLinha(){?}
public No getAnt(){?}
public No getProx(){?}
public void setLinha(String80 Linha){?}
public void setAnt(No ant){?}
public void setProx(No prox){?}
}

Alguem tem ideia de como posso fazer, um exemplo?
Agradesço desde ja!

Criado 15 de outubro de 2008
Ultima resposta 14 de out. de 2012
Respostas 16
Participantes 8