title: How to place a JButton at a desired location in a JFrame using Java?
body: <p>I want to put a <code>JButton</code> at a particular <strong>coordinate</strong> in a <code>JFrame</code>. I used <code>setBounds()</code> for the <code>JPanel</code> (which I placed on the <code>JFrame</code>) and also <code>setBounds()</code> for the <code>JButton</code>. However, they don't seem to function as expected.</p>
  <p>My Output:</p>
  <p><a href="https://i.stack.imgur.com/mxlFq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxlFq.jpg" alt="alt text" /></a></p>
  
  <p>This is my code:</p>
  <pre><code>import java.awt.Color;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  
  public class Control extends JFrame {
  
      // JPanel
      JPanel pnlButton = new JPanel();
      // Buttons
      JButton btnAddFlight = new JButton(&quot;Add Flight&quot;);
  
      public Control() {
          // FlightInfo setbounds
          btnAddFlight.setBounds(60, 400, 220, 30);
  
          // JPanel bounds
          pnlButton.setBounds(800, 800, 200, 100);
  
          // Adding to JFrame
          pnlButton.add(btnAddFlight);
          add(pnlButton);
  
          // JFrame properties
          setSize(400, 400);
          setBackground(Color.BLACK);
          setTitle(&quot;Air Traffic Control&quot;);
          setLocationRelativeTo(null);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
      }
  
      public static void main(String[] args) {
          new Control();
      }
  }
  </code></pre>
  <p>How do I place the <code>JButton</code> at coordinate (0, 0)?</p>