我正在尝试使用 JMenuItem 删除和添加我需要的面板。然而,当我使用动作监听器并告诉它添加一个面板时,什么都没有发生。
PanelMaker newPanel = new Panel(); //I have my panel in another class and I use this to call it
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
add(newPanel.pane());//I try to add the panel here, but nothing occurs
}
});