private void menuButtonActionPerformed(java.awt.event.ActionEvent evt) {
panel1.setVisible(false);
startMenu.setVisible(true);
img = new ImageIcon("DeathRun.png");
Graphics g = startMenu.getGraphics();
img.paintIcon(null, g, 0, 0);
}
The code is very simple for this method but here is my problem. I have a menu that I want to display an image behind. When I hit the menu button the menu comes up the image flashes VERY quickly and only part of it flashes, then it goes away.
If I set a button on the menu to run just the last 3 lines of the code above then the image shows up in the background which is what I want. So why can't I click on a button in a different panel, bring up the menu panel and show the image? It just doesn't make sense.
I've done a little testing and I threw startMenu.paintAll(g) behind the code in the button that DOES show the image, and it does the same thing as when I switch panels and try to show the image.