title: JAVA: How come I cannot have more than two JLabels in the same vertical position (different horizontal positions)?
body: <p>I am creating a GUI with three labels. I used the setBounds method on each label, and the first two labels are in the x and y positions that I passed in the parameters. However, the third label is simply sitting at the left. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>principleLabel = new JLabel(); 
  principleLabel.setText("Principle");
  principleLabel.setBounds(101, 10, 100, 50);
  frame.getContentPane().add(principleLabel); 
  
  rateLabel = new JLabel(); 
  rateLabel.setText("Rate (Percentage)");
  rateLabel.setBounds(295, 10, 150, 50);
  frame.getContentPane().add(rateLabel); 
  
  yearsLabel = new JLabel(); 
  yearsLabel.setText("Years");
  yearsLabel.setBounds(555, 10, 50, 50);
  frame.getContentPane().add(yearsLabel); 
  </code></pre>
  
  <p>I tried putting the labels in different orders, and I saw it is always the one written last that is behaving weirdly. </p>
  
  <p><a href="https://i.stack.imgur.com/BgG2a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BgG2a.png" alt="My GUI"></a></p>
  
  <p>I would appreciate any help. Thank you. </p>