getContentPane().setLayout(new CardLayout());
CardLayout x = (CardLayout) getLayout();
I'm using Netbeans and in Design manager I chosed my JFrame contents as CardLayout. However I cannot make it work so far. I set the above code after the initComponenets call and still I have this error:
java.awt.BorderLayout cannot be cast to java.awt.CardLayout
Somehow I have BorderLayout instead of CardLayout. How is it possible? I've just set layout as CardLayout. PS: my class extends javax.swing.JFrame.