title: Java JLabel background color not working?
body: <p>I'm learning how to create application in Java.</p>
  
  <p>I'm having trouble getting the JLabel to have a background color whilst the JPanel is white, behind it. Also, is there a way to resize the JPanel to half of what the JFrame is?</p>
  
  <p>Any help would be very much appreciated. Thank you.</p>
  
  <hr>
  
  <pre><code>   package PracticeOne;
  
      import java.awt.BorderLayout;
  
      public class PracticeOne {
  
          public static void main(String[] args) {
  
  
              Frame container = new Frame();
              Panel box = new Panel();
              Label txt = new Label();
  
              box.add(txt);
  
              container.add(box, BorderLayout.CENTER);
  
  
          }
  
      }
  </code></pre>
  
  <hr>
  
  <pre><code>package PracticeOne;
  
  import javax.swing.JFrame;
  
  public class Frame extends JFrame {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
      Frame(){        
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          this.setSize(500, 500);
  
          this.setVisible(true);
  
          this.setLocationRelativeTo(null);
  
          this.setTitle("Testing this out");
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package PracticeOne;
  
  import java.awt.Color;
  import java.awt.Dimension;
  import javax.swing.JPanel;
  
  public class Panel extends JPanel {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
  
      public Dimension d = new Dimension(100,100);
  
      Panel(){
          this.setSize(d);
          this.setAlignmentX(CENTER_ALIGNMENT);
          this.setBackground(Color.WHITE);
  
      }
  
  
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package PracticeOne;
  
  import java.awt.Color;
  
  import javax.swing.JLabel;
  
  public class Label extends JLabel {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
  
  
      Label(){
          this.setSize(50, 50);
  
  
          this.setText("ya boy is working here");
          this.setForeground(Color.BLACK);
          this.setBackground(Color.ORANGE);
  
      }
  }
  </code></pre>