如何制作JavaPDF专属文件explorer/viewer

how to make Java PDF exclusive file explorer/viewer

我是一个 Java 编程新手,我的任务是构建一个 Java 文件浏览器,但它必须是 PDF 专用的。它必须能够在整个 HDD 中搜索 PDF 文件,并能够列出它们并通过双击使它们可供查看。它还必须有一个刷新按钮,这样您就不必关闭并重新打开程序,从而搜索和查看另一个文件。任何帮助将不胜感激。

我也将其作为文件浏览器的图形用户界面

package pdfView;

import javax.swing.*;
import java.awt.*;

public class View extends JFrame {
    public View() {
        super("PDF Viewer");
        setLookAndFeel();
        setSize(500, 125);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        FlowLayout flo = new FlowLayout();
        setLayout(flo);
        JTextField Search = new JTextField ("Search", 29);
        JButton Search1 = new JButton("Search");
        JButton ReFresh = new JButton("ReFresh");
        add(Search);
        add(Search1);
        add(ReFresh);

        setVisible(true);
    }

    private void setLookAndFeel() {
        try {
            UIManager.setLookAndFeel(
                    "com.sun.java.squing.plaf.nimbus.NimbusLookAndFeel"
                    );
        } catch (Exception exc){

        }
    }

    public static void main(String[] args) {
        View pdf = new View();
    }

}

如果我是你,我会使用JFileChooser. It is built into java by default. You can also filter the files so that only .pdf documents show up. From there, there are several libraries that let you extract text from the pdf such as PDFBox