How do I switch between JPanels in an applet? Switching between JPanels in a JFrame is very easy and I do it like this:
frame.remove(mainMenu); //remove the old jpanel
frame.add(game); //add the new jpanel
game.createImage(); //runs createVolatileImage(width, height)
//in the other class (JPanel)
frame.revalidate();
frame.repaint();
requestFocus();
However, how do I replicate this in an applet? When I try this in an applet, I get a nullPointerException when I try to run image.getGraphics()
on the image that I created in the new JPanel.