Java Intellij:将“接口”添加到项目窗格中的上下文菜单中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3385232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 22:49:01  来源:igfitidea点击:

Intellij: Adding 'Interface' to my context menu in the Project Pane

javasettingsintellij-idea

提问by digiarnie

Currently in IntelliJ, if I right-click a package in the Project pane, I can see things such as:

目前在 IntelliJ 中,如果我在“项目”窗格中右键单击一个包,我可以看到以下内容:

new > Java class
new > File
new > Package

I want to add some new menu items in the 'new' context menu such as Interface and Enum. Does anyone know how to do this?

我想在“新”上下文菜单中添加一些新菜单项,例如界面和枚举。有谁知道如何做到这一点?

I've been playing around in the Settings > Menus and Toolbarswithout any luck.

我一直在“设置”>“菜单和工具栏”中玩,但没有任何运气。

Edit: The funny thing is if I right click a package and choose New > Edit File Templates..., I can see the template for an Interface and in the description it actually says:

编辑:有趣的是,如果我右键单击一个包并选择New > Edit File Templates...,我可以看到接口的模板,并且在描述中它实际上说:

This is a built-in template used by IDEA each time you create a new Java interface, by selecting New | Interface from the popup menu in one of the project views.

Unless I need to look at a different pane other than Project, I can't seem to find any context menu that lets me choose New > Interfaceas suggested by the above description.

除非我需要查看除Project之外的其他窗格,否则我似乎找不到任何上下文菜单可以让我按照上述说明的建议选择New > Interface

采纳答案by CrazyCoder

New | Java Class, Create New Classdialog appears, in this dialog you can choose Kindbetween one of the following:

新 | 出现 Java 类,创建新类对话框,在此对话框中,您可以在以下选项之一中选择种类

  • Class
  • Interface
  • Enum
  • Annotation
  • 班级
  • 界面
  • 枚举
  • 注解

(tested with IDEA 9.0.3)

(使用 IDEA 9.0.3 测试)

If you want Interface directly in the New list, then you have to add new template in Settings | File Templates, name it something like Java Interfaceand copy the contents of the Interfacetemplate into this one.

如果你想直接在新建列表中的界面,那么你必须在设置 | 添加新模板。文件模板,将其命名为Java Interface 之类的名称,并将Interface模板的内容复制到该模板中。

回答by Mehraj Malik

Also you can create a shortcut to save some secs.

您也可以创建一个快捷方式来节省一些时间。

Alt+Ctr+S-> Keymap-> in search box type 'create new' and select Java classand then assign any shortcut like Ctrl+N.

Alt+Ctr+S-> Keymap-> 在搜索框中键入“ create new”并选择Java class并分配任何快捷方式,例如Ctrl+N.

enter image description here

在此处输入图片说明

回答by Yekta ?zdemir

It's under the New Java Class menu.

它位于 New Java Class 菜单下。