All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.appdapter.gui.swing.FileMenu Maven / Gradle / Ivy

Go to download

Appdapter Maven project including Java and Scala, produces jar, not bundle. Excludes concrete SLF4J binding.

The newest version!
package org.appdapter.gui.swing;

import java.io.File;
import java.util.Iterator;
import java.util.Vector;

import javax.swing.Action;

import org.appdapter.gui.browse.Settings;

public class FileMenu extends SafeJMenu {


	/**
	 *
	 */
	private final CollectionEditorUtil collectionEditorUtil;
	Vector recentFiles = new Vector();

	FileMenu(String name, CollectionEditorUtil val) {
		super(false, name, val);
		this.collectionEditorUtil = val;
		try {
			addItems();
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}

	private void addItems() {
		add(this.collectionEditorUtil.newAction);
		add(this.collectionEditorUtil.openAction);
		addSeparator();
		add(this.collectionEditorUtil.saveAction);
		add(this.collectionEditorUtil.saveAsAction);
		addSeparator();

		recentFiles = new Vector();
		Iterator it = Settings.getRecentFiles();
		while (it.hasNext()) {
			File file = (File) it.next();
			Action a = this.collectionEditorUtil.new RecentFileAction(file);
			recentFiles.addElement(a);
			add(a);
		}
	}

	public void refreshRecentFileList() {
		removeAll();
		addItems();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy