Need help with objects that "paint"

EDIT: I’ve re-posted the proper code, and made my problem more clear. (I hope) At least now people will be looking at the right thing and not guessing at what they think my true problem is.

Zones extends a JPanel, which is added to a JFrame called Dorothy. When done this way, Zones doesn’t work as planned. When I declare it as it’s own class (public class Zones extends JFrame) and override it’s paint function, it works the way I want. Details below.

What it should be doing:

  1. Show user the sequence
  2. Allow user to click squares
  3. if right, Go to 1.
  4. if wrong, show reset button that Goes to 1 on click.

What it does when inside another container:

  1. Freeze as the splash screen is hidden, and it is set to visible.
  2. unfreezes, allowing the player to interact (no sequence shown)
  3. Allow user to click squares
  4. if right, Freeze (no sequence shown), go to 2.
  5. if wrong, show reset button. When clicked, freezes. Go to 2.

The user needs to see what Simon says to play. :-\

Apologies for not providing the code in the post, I was forced to provide a file because I reached the “10000” character limit, despite what Office and 2 online character counters said. (Said I had 9655 :P)

Yeah, you don’t want to draw stuff directly into a JFrame, you want it to be drawn in a JPanel. What would work would be to just make a private class that’s an implementation of JPanel with the paint method overridden. Then add that to the main JFrame as its sole component and it should work right.

Edit: Reposted proper code so it’s more clear. See Above.

You would probably be better off fixing the problems with the JPanel implementation. Both examples you gave are extending JFrame so it’s impossible to help with the JPanel problems. To add a working class that extends JPanel to a JFrame you can use this simple code:


static public void main(String[] args){
   JFrame frame = new JFrame();
   frame.add(new MyJPanel());  //Changed to the actual name you use
   frame.pack();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
}