Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用IntelliJ'的卡布局;什么是表单生成器?_Java_Intellij Idea_Cardlayout - Fatal编程技术网

Java 如何使用IntelliJ'的卡布局;什么是表单生成器?

Java 如何使用IntelliJ'的卡布局;什么是表单生成器?,java,intellij-idea,cardlayout,Java,Intellij Idea,Cardlayout,当我使用卡片布局按下下一个按钮时,我很难让我的程序切换JPanel 这就是它看起来的样子: 我希望程序切换到“customerSearch”JPanel。它有卡名&卡名2。panelContainer具有卡片布局。我做错了什么 public class Gui { private JPanel panelContainer; private JPanel takeoutOption; private JPanel customerSearch; private JButton nextButt

当我使用卡片布局按下下一个按钮时,我很难让我的程序切换JPanel

这就是它看起来的样子:

我希望程序切换到“customerSearch”JPanel。它有卡名&卡名2。panelContainer具有卡片布局。我做错了什么

public class Gui {
private JPanel panelContainer;
private JPanel takeoutOption;
private JPanel customerSearch;
private JButton nextButton;

private CardLayout cl = (CardLayout)panelContainer.getLayout();


public Gui() {

    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            cl.show(panelContainer, "Card2");
        }
    });
}

我能解决这个问题。我发现我的代码是正确的。相反,问题是该按钮无法使用表单上的预览功能。