Aanal
Aanal

Reputation: 21

how to maintain history of recent files/folders inOpen Dialogbox in java swing?

I want to maintain history of last 5 or 6 open folder/files which i have recently opened in Open DialogBox as drop down list...how can I do it in java Swing???

Upvotes: 2

Views: 1987

Answers (3)

Gursel Koca
Gursel Koca

Reputation: 21300

You should use java preference api, to store previously opened folders/files. And also you shold customize JFileChooser as suggested by previous answer to display these folders and files.

Upvotes: 1

Stephen C
Stephen C

Reputation: 718788

There is nothing that directly provides history in the JFileChooser API. However, this old JavaWorld article may give you the hints you need.

Upvotes: 3

Harry Joy
Harry Joy

Reputation: 59660

Use setSelectedFile(File file) method of JFileChooser.

The doc says:

public void setSelectedFile(File file)

Sets the selected file. If the file's parent directory is not the current directory, changes the current directory to be the file's parent directory.

Parameters: file - the selected file

Here is the link for the doc.

Upvotes: 1

Related Questions