Java 从actionListener中打开新JFrame

Java 从actionListener中打开新JFrame,java,Java,我有一个程序,在JFrame上有几个按钮。我想让其中一个打开另一个JFrame和一个JTextField。第一个“单击开始”按钮调用两个工作良好的方法。但是我不知道如何为登录投票按钮创建第二个文本框 我现在的代码是这个 public class event implements ActionListener { public void actionPerformed(ActionEvent e) { String command = e.getActionComman

我有一个程序,在JFrame上有几个按钮。我想让其中一个打开另一个JFrame和一个JTextField。第一个“单击开始”按钮调用两个工作良好的方法。但是我不知道如何为登录投票按钮创建第二个文本框

我现在的代码是这个

public class event implements ActionListener {

    public void actionPerformed(ActionEvent e) {

        String command = e.getActionCommand();

        if (command.equals("Click to Start")) {

            createBeginWindow();
            panelAdder();

        } else if (command.equals("Login to Vote")) {


            //This is where I want to create the JFrame. VoterID would be what is written in the JTextField.
            String voterID = (_text.getText());
            //And then I would use this string in other methods

        }
    }
}

您可以简单地调用新帧:

else if (command.equals("Login to Vote")) {

          JFrame ob = new JFrame("new Frame");
           ob.setVisible(true);
        String voterID = (_text.getText());
    }
else if(command.equals(“登录投票”){JFrame ob=new JFrame();ob.setVisible(true);String voterID=(_text.getText());}