且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎样才能在java中打开.pdf文件

更新时间:2022-06-11 00:16:11

ActionListener listener = new MyListener();
        butt.addActionListener(listener);

在我的监听器中添加此

if (Desktop.isDesktopSupported()) {
            try {
                File myFile = new File( "path/to/file");
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                // no application registered for PDFs
            }
        }