2017-03-16 69 views
1

我正在创建intelliJ插件并注册我的动作,在我的动作内我想显示一个输入对话框与多个文本框,我该怎么做? 我只显示一个文字框的一个例子 -intellij插件开发显示与多个文本框的输入对话框

String txt= Messages.showInputDialog(project, "What is your name?", 
            "Input your name", Messages.getQuestionIcon()); 

回答

1

创建一个新的GUI表单(form +类)。类应该延伸DialogWrapper并覆盖方法。

里面createCenterPanel()返回你的根JPanel。在返回JPanel之前,您可以设置任何默认值,将事件侦听器添加到文本框等。

执行Action接口,您希望在单击确定按钮时获取该值。将此操作传递给您的表单类。

getOKAction()应该返回这个动作。

以下代码来自我目前正在处理的插件。希望这会给你一些想法,但将不得不适应你的需要。

public class ReleaseNoteDialog extends DialogWrapper implements Action { 
    private JTextArea txtReleaseNote; 
    private JPanel panelWrapper; 

    ....... 
    protected JComponent createCenterPanel() { 
     ...... 
     return panelWrapper; 
    } 
    ...... 
    @Override 
    protected Action getOKAction() { 
     return this; 
    } 
    ....... 
    @Override 
    public void actionPerformed(ActionEvent e) { 
     // save value to project state 
     super.doOKAction(); 
    }