我正在显示一个文件列表; 即我的Java应用程序(Eclipse RCP)中的xls,doc,pdf,odt等.当用户单击该文件时,我想启动相应的(根据操作系统认为的)本机应用程序,就像在Windows资源管理器或Finder中一样.
当我在这里时:最好还显示Finder或Explorer用于不同文件类型的相同图标.
是否有一个库或Eclipse插件?
这是我的 jFileChooser 摆动代码,它在单击打开按钮后打开另一个窗口。然后我们需要在第二个窗口中选择相应的文件,以便实际打开该文件。我需要对第一个窗口本身进行所有操作。
import com.opencsv.CSVReader;
import java.awt.*;
import java.awt.event.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
/*
* Created by JFormDesigner on Tue Sep 22 13:24:36 IST 2015
*/
/**
* @author Avinash Raj
*/
public class FileChooser extends JFrame {
private JFileChooser fileChooser1;
public FileChooser() {
initComponents();
}
private void fileChooser1ActionPerformed(ActionEvent e) {
int returnVal = fileChooser1.showOpenDialog(FileChooser.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
//File file = fc.getSelectedFile();
setVisible(false);
String path=fileChooser1.getSelectedFile().getAbsolutePath();
String filename=fileChooser1.getSelectedFile().getName();
//This is where a real …Run Code Online (Sandbox Code Playgroud)