title: Trying to make a simple calculator, JButtons aren't showing up. Why?
body: <p>I can't get my <code>Jbuttons</code> to show up on my <code>JPanel</code> or <code>JFrame</code>, I'm new to programming still and struggling. </p>
  
  <p>SimpleCalculator:</p>
  
  <pre><code>package simplecalculator;
  
  public class SimpleCalculator {
  
   public static void main(String[] args) {
      MyFrame aFrame = new MyFrame();
      aFrame.setVisible(true);
    }
  
  }
  </code></pre>
  
  <p>MyFrame:</p>
  
  <pre><code>import javax.swing.*;
  
  public class MyFrame extends JFrame { 
  
   public MyFrame(){
     super();
  
     this.setTitle("Simple Calculator");
     this.setVisible(true);
     MyPanel aPanel = new MyPanel();
     this.getContentPane().add(aPanel);
     aPanel.setVisible(true);
     this.setSize(500, 300);
     }
    }
  </code></pre>
  
  <p>MyPanel:</p>
  
  <pre><code>package simplecalculator;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.*;
  
  public class MyPanel extends JPanel implements ActionListener {
   int ans=0;
  
   JTextField result = new JTextField();
   JButton but0 = new JButton("0");
   JButton but1 = new JButton("1");
   JButton but2 = new JButton("2");
   JButton but3 = new JButton("3");
   JButton but4 = new JButton("4");
   JButton but5 = new JButton("5");
   JButton but6 = new JButton("6");
   JButton but7 = new JButton("7");
   JButton but8 = new JButton("8");
   JButton but9 = new JButton("9");
  
  
   public MyPanel() {
      super();
  
      result.setVisible(true);
      result.setLocation(20, 20);
      but0.setText("0");
      but0.setVisible(true);
      but0.setLocation(40, 40);
    }
  </code></pre>
  
  <p>I'm trying to make a simple calculator but I'm stuck. Someone please help.</p>