title: paint() doesn't work after panel and frame was added
body: <p>I am making kind of my paint that creates shapes, it worked fine until I added layers(panel and frame), now the shapes aren't visible on button press I assume it is under the layers?i tried using paintComponent and revalidate etc and still couldn't get it to appear</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  public class Main2 extends JPanel implements ActionListener {
  
      private static Square mySquare;
      private static Circle myCircle;
      private static Color myColor;
      public boolean SquareCheck;
      public boolean CircleCheck;
      JButton buttonSquare;
      JButton buttonCircle;
      JFrame frame;
      JPanel panel;
  
      public void paint(Graphics g) {
          if (SquareCheck) {
              g.setColor(myColor);
              g.fillRect(mySquare.x, mySquare.y, mySquare.width, mySquare.length);
          } else if (CircleCheck) {
              g.setColor(myColor);
              g.fillOval(myCircle.x, myCircle.y, myCircle.width, myCircle.length);
          }
      }
  
      public void start() {
          frame = new JFrame();
          panel = new JPanel();
  
          //setLayout(new BorderLayout());
  
          buttonSquare = new JButton("■");
          buttonCircle = new JButton("●");
  
          buttonSquare.setPreferredSize(new Dimension(200, 20));
          buttonCircle.setPreferredSize(new Dimension(200, 20));
  
          buttonCircle.addActionListener(this);
          buttonSquare.addActionListener(this);
          //add(buttonCircle, BorderLayout.NORTH);
          //add(buttonSquare, BorderLayout.SOUTH);
          JToggleButton red = new JToggleButton();
          panel.add(buttonCircle);
          panel.add(buttonSquare);
          frame.add(panel);
          frame.setSize(500, 500);
          frame.setVisible(true);
  
      }
  
      public void actionPerformed(ActionEvent e) {
  
          if (e.getSource() == buttonSquare) {
              SquareCheck = true;
          } else if (e.getSource() == buttonCircle) {
              CircleCheck = true;
          }
          repaint();
  
      }
      public static void main(String[] args) {
          mySquare = new Square(30, 50, 50, 50);
          myCircle = new Circle(60, 100, 50, 50);
          myColor = Color.red;
          Main2 x = new Main2();
          x.start();
  
      }
  }
  </code></pre>
  
  <p>Basiclly the buttons changes the boolean then the repaint is called and based on the boolean it draws either a cirlce or a square,the code worked before adding frame and panel </p>