我已经做了一个按钮,但我现在不知道如何使它打开一个特定的目录,如%appdata%
点击按钮时。如何制作一个按钮,点击后打开%appdata%目录?
这里是代码 - >
//---- button4 ----
button4.setText("Texture Packs");
button4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JFileChooser fileChooser=new JFileChooser("%appdata%");
int status = fileChooser.showOpenDialog(this);
fileChooser.setMultiSelectionEnabled(false);
if(status == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
// do something on the selected file.
}
}
我想让这样的事情 - >
private void button4MouseClicked(MouseEvent e) throws IOException {
open folder %appdata%
// Open the folder in the file explorer not in Java.
// When I click on the button, the folder is viewed with the file explorer on the screen
}
是否要打开文件选择器或系统文件资源管理器? – Vulcan
我想在系统文件浏览器中打开 – Malasuerte94
我在一个月前为此写了一个[FileExplorer class](http://textu.be/6)。我还发布了更详细的答案。 – Vulcan