title: How to move JButtons and JLabels position in a JPanel, JFrame
body: <p>I am creating a simple lottery as a practice, I am a beginner of Java. I have achieved almost everything that I want apart from one thing: Moving the different texts and buttons to the position that I'd like them to be.</p>
  
  <p>Here is a picture edited in Photoshop  describing how I would like it to be:</p>
  
  <p><img src="https://i.stack.imgur.com/2AMap.png" alt="http://i.gyazo.com/9587eb7e451b90ea0f920c4795a03cd5.png"></p>
  
  <p>The Lottery currently looks like this after you press the Play button:</p>
  
  <p>(As you can see the buttons get shifted to the right in order to make space for the text that is squished in to the left of the buttons)</p>
  
  <p><img src="https://i.stack.imgur.com/84yX3.png" alt="enter image description here"></p>
  
  <p>What I'm looking to achieve is for the buttons position to never move, and to put the text under the buttons.</p>
  
  <p>I would also like to add a table that describes your potential winnings and what number will give you what winnings.</p>
  
  <p>The code consists of 2 Java Classes, and please remember that I am a beginner and if you see any simple room for improvement (I know there must be plenty) I would be glad if you gave me a tips or anything :)</p>
  
  <p>So this is the code:</p>
  
  <p>LotteryMain.Java</p>
  
  <pre><code>public class LotteryMain {
  /**
   **@author Samy
   */
  public static void main(String[] args) {
  
      TheLottery n = new TheLottery();
      n.TheLottery();
  
  }
  }
  </code></pre>
  
  <p>TheLottery.java</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.FlowLayout;
  import java.awt.HeadlessException;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.AbstractButton;
  import javax.swing.JButton;
  import javax.swing.JLabel;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.SwingConstants;
  import javax.swing.border.EtchedBorder;
  
  public class TheLottery extends JFrame implements ActionListener {
  /**
   **author Samy
   */
  
  JFrame frame = new JFrame("The Lottery");
  JPanel panel = new JPanel(new FlowLayout());
  JButton play = new JButton("Play");
  JButton exit = new JButton("Exit");
  JLabel label = new JLabel();
  
  private static final long serialVersionUID = 1L;
  
  
  
  public void TheLottery() {
  
  
      panel.add(label);
  
      int width = 720;
      int height = width/16*9;
  
      frame.setSize(width,height);
      frame.setResizable(false);
      frame.setLocationRelativeTo(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setUndecorated(true);
      frame.add(panel);
  
      panel.setBackground(new Color(0x222222));
      panel.setBorder(new EtchedBorder(new Color(0xAAAAAA),new Color(0x666666)));
      panel.add(play);
      panel.add(exit);
  
  
  
      play.addActionListener(this);
      exit.addActionListener(this);
  
      play.setToolTipText("Click me to play the lottery!");
      exit.setToolTipText("Click me to exit.");
  
      frame.setVisible(true);
  
  }
  
  
  
  @Override
  public void actionPerformed(ActionEvent e) {
  
      Object action = e.getSource();
  
      String winnings = null;
      double lotteryChance = Math.random()*100;
  
      if(action == play) {
  
          if (lotteryChance &gt; 80) {
              winnings = ("You lost! Luckily this lottery is free to play.");
          } else if (lotteryChance &lt; 80 &amp;&amp; lotteryChance &gt; 50) {
              winnings = ("You've won $100!");
          } else if (lotteryChance &lt; 50 &amp;&amp; lotteryChance &gt; 20) {
              winnings = ("You've won $500!");
          } else if (lotteryChance &lt; 20 &amp;&amp; lotteryChance &gt; 5) {
              winnings = ("You've won $2,000!");
          } else if (lotteryChance &lt; 5 &amp;&amp; lotteryChance &gt; 1) {
              winnings = ("You've won $5,000!");
          } else if (lotteryChance &lt; 1 &amp;&amp; lotteryChance &gt; 0.1) {
              winnings = ("You've won $25,000!");
          } else if (lotteryChance &lt; 0.1 &amp;&amp; lotteryChance &gt; 0.01) {
              winnings = ("You've won $50,000!");
          } else if (lotteryChance &lt; 0.01 &amp;&amp; lotteryChance &gt; 0.001) {
              winnings = ("You've won $250,000!");
          } else if (lotteryChance &lt; 0.001 &amp;&amp; lotteryChance &gt; 0) {
              winnings = ("YOU'VE WON THE JACKPOT OF $1,000,000!");
          } else winnings = ("Something went wrong, no winnings this round.");
  
  
          System.out.println("Your number is: "+lotteryChance);
          System.out.println(winnings);   
      }   
      if(action == exit) {
          System.exit(1);
      }
      label.setText("&lt;html&gt;&lt;font color='white'&gt;Your number is: "+lotteryChance+" -                                               "+winnings+"&lt;/font&gt;&lt;/html&gt;");
  
  }
  }
  </code></pre>