Trying to make flashcard application. The JButton b_switchmode will be used to switch between panels (an edit mode and a test mode, both have panels created for separate use). Not quite sure how to go from the GUI I've created. Ideally I would click the JButton b_switchmode and I would be able to switch from "Edit Mode" to "Test Mode".
I'm aware that a CardLayout may be needed but I'm unable to implement the correct syntax to make the program executable.
So I want to know how to:
- insert - CardLayoutto be able to switch between- JPanels
- allow - JButton b_switchmodeto execute the switch between- JPanels
public class App2 {
    private static JFrame frame;
    private static JPanel editpanel;
    private static JPanel testpanel; 
    private static JLabel l_appmode;
    private static JLabel l_number;
    private static JLabel l_question;
    private static JLabel l_answer;
    public  static JTextField t_questions;
    public  static JTextField t_answer;
    public  static JButton    b_switchmode;
    public  static JButton    b_previous;
    public  static JButton    b_next;
    public  static JButton    b_add;
    public  static JButton    b_save;
    public  static JButton    b_question;
    public  static JButton    b_answer;
    static int width  = 600;
    static int height = 450;
public static void main(String[] args) {
    // TODO Auto-generated method stub
    gui();
}
private static void gui(){
  frame = new JFrame("Assignment2");
  frame.setTitle("Flash Cards");
  frame.setSize(width,height);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  l_appmode  = new JLabel("Current Mode: Edit");  
  l_number = new JLabel ("");
  l_question  = new JLabel("Question:");
  l_answer    = new JLabel("Answer:");
  t_questions = new JTextField("");
  t_answer    = new JTextField("");
  b_switchmode = new JButton("Switch Mode");
  b_previous = new JButton("Previous");
  b_next = new JButton("Next");
  b_add = new JButton("Add");
  b_save = new JButton("Save");
  b_question = new JButton("Question");
  b_answer = new JButton("Answer");
  editpanel = new JPanel();
  int rows = 6, columns = 1;
  int hgap = 20; int vgap = 20;
  editpanel.setLayout(new GridLayout(rows, columns, hgap, 
  vgap));
  editpanel.add(l_appmode);
  editpanel.add(l_number);
  editpanel.add(l_question);
  editpanel.add(t_questions);
  editpanel.add(l_answer);
  editpanel.add(t_answer);
  editpanel.add(b_switchmode);
  editpanel.add(b_previous);
  editpanel.add(b_next);
  editpanel.add(b_add);
  editpanel.add(b_save);
  //testpanel.add(b_question);
  //testpanel.add(t_questions);
  //testpanel.add(b_answer);
  //testpanel.add(t_answer);
  frame.add(editpanel);
  //frame.add(testpanel);
  frame.setVisible(true);
}
 
    