title: How to get this JButton to work?
body: <p>I am having some serious trouble on JButtons. My problem is that the JButton just won't show up, no matter what I try. I've been trying everything for over an hour, and nothing has worked, so I think it is time to ask here. Here is my code. It's just the constructor because the whole class is really big and you don't need to see it.</p>
  
  <pre><code>public Game() {
  
      frame = new JFrame(NAME);
      canvas = new Canvas();
  
      canvas.setMinimumSize(new Dimension(width, height));
      canvas.setMaximumSize(new Dimension(width, height));
      canvas.setPreferredSize(new Dimension(width, height));
      canvas.setFocusable(false);
  
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLayout(new BorderLayout());
      frame.setSize(width, height);
  
      frame.add(canvas, BorderLayout.CENTER);
  
      frame.setResizable(false);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
      frame.setFocusable(true);
      frame.requestFocus();
  
      JPanel panel = new JPanel();
      JButton play = new JButton("Hi");
  
      panel.add(play);
      frame.getContentPane().add(panel);
      panel.setPreferredSize(new Dimension(width, height));
  
  }
  </code></pre>