Skip to content

Instantly share code, notes, and snippets.

Created November 19, 2014 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/402e6d9956a77feaac60 to your computer and use it in GitHub Desktop.
Save anonymous/402e6d9956a77feaac60 to your computer and use it in GitHub Desktop.
import javax.swing.ActionMap;
import javax.swing.JPanel;
import javax.swing.text.DefaultEditorKit;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.util.Lookup;
public class ExplorerManagerProviderPanel extends JPanel
implements ExplorerManager.Provider, Lookup.Provider
{
private final ExplorerManager explorerManager = new ExplorerManager();
private final Lookup lookup;
public ExplorerManagerProviderPanel() {
ActionMap map = this.getActionMap();
map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(explorerManager));
map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(explorerManager));
map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(explorerManager));
map.put("delete", ExplorerUtils.actionDelete(explorerManager, true));
lookup = ExplorerUtils.createLookup(explorerManager, map);
}
@Override
public final ExplorerManager getExplorerManager() {
return explorerManager;
}
@Override
public final Lookup getLookup() {
return lookup;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment