开发者

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 ope开发者_运维技巧ned in Open DialogBox as drop down list...how can I do it in java Swing???


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜