It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes File listing using swings.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "File listing using swings...." Watch "File listing using swings...." New topic

File listing using swings....

remi vandana

Joined: Aug 24, 2001
Posts: 6
pl. help me out in acheiving the foll:
U all must hv seen tht while using std Word or any Microsoft prod, When we clk on File menu we get the listing of recently opened files before "exit" menu item.
whtevr file r opened or closed it appears in the list.
Same file list also appears whn we clk on "window" menu item. but the no.of file here are just 3 most recent files whereas whn ths appears on "File" menulist thn the no.of most recently opened files are 8.
i also want to implement this in my GUI.
i hv made Menu using JMenu, Jmenuitems etc.
I want same std word file listing implementation here too...
pl. reply soon....
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Hi remi,
I have been thinking about this too for one of my applications, but haven't actually done it yet.
The way I'm going to approach this is
1) When you open a file you will need to add it's path and name to some text file which always holds, say, 8 filenames in a list (files separated by new lines). If there are already 8 files in the list, remove the first one and add the new one to the end.
2) Use this file when you are creating your swing JMenu. First, read the text file list into an array of Strings with 8 elements. Then, use the values of these array elements in a loop to generate new JMenuItems, soemthing like the following:

If you make any progress with this, I would be interested to know how you do it.
hope this is of some use.
[This message has been edited by Ben Wood (edited August 29, 2001).]

SCJP 1.4,
I agree. Here's the link:
subject: File listing using swings....
It's not a secret anymore!