如何在CardLayout
.
也就是说,如果一个面板是另一个“容器”面板中的卡,那么如何从卡中获取对这个“容器”面板的引用?
这就是我正在做的事情:-
public class LogInPanel extends javax.swing.JPanel implements ActionListener{
/**
* Creates new form Panel2
*/
private JPanel parentPanel;
private CardLayout c1=null;
public LogInPanel() {
initComponents();
//c1=new CardLayout();
parentPanel=(JPanel)(SwingUtilities.getAncestorOfClass(this.getClass(), this));
c1=(CardLayout)(parentPanel.getLayout());
submitLogin.addActionListener(this);
}
...