title: Adding a JPanel into JFrame
body: <p>I have a class <code>BoardGUI</code> that extends <code>JFrame</code>. I have added buttons in a <code>JPanel</code>. When I try to add the panel into the frame with a mouselistoner on the frame, the buttons (undo and replay) become invisible. When I mouse over the buttons, they become visible.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class BoardGUI extends JFrame {
      JButton a=new JButton("Undo");
      JButton r=new JButton("replay");
      JPanel jp=new JPanel();
  
      public BoardGUI() {
  
          // TODO Auto-generated constructor stub
          setTitle("Checkers Game");
          setSize(645, 700);
  
          jp.setLayout(new FlowLayout());
          jp.setPreferredSize(new Dimension(645,35));
          a.setVisible(true);
          r.setVisible(true);
          jp.add(a);
          jp.add(r);
          add(jp,BorderLayout.SOUTH);
          setVisible(true);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          addMouseListener(new MouseListener() {
  
              @Override
              public void mouseReleased(MouseEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void mousePressed(MouseEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void mouseExited(MouseEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void mouseEntered(MouseEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void mouseClicked(MouseEvent arg0) {
                  // TODO Auto-generated method stub
                  repaint();
  
              }
          });
  
  
      }
      public void paint(Graphics g)
      {
          for(int i=0;i&lt;8;i++)
          {
              for(int j=0;j&lt;8;j++)
              {
                  g.fillRect(i*100, j*100, 100, 100);
              }
          }
      }
  }
  </code></pre>
  
  <p>Can anybody help me to fix this please?</p>