我已經做了一個按鈕,但我現在不知道如何使它打開一個特定的目錄,如%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