title: java - JTextField wont show properly
body: <p>I'm working on a small java project and the end goal is a program that tells you how many days are in a specified month. My problem is only one of my textfields is showing up in the GUI! I have no idea why this is happening and have been looking around for a solution for about 2 hours. Please Help! p.s. I'm a novice programer, at least in java so this may be an obvious answer!</p>
  
  <p>My code:</p>
  
  <pre><code>package main;
  
  import java.awt.Dimension;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  @SuppressWarnings({ "unused", "serial" })
  public class Test extends JFrame {
    JTextField text;
    JTextField text2 = new JTextField("Enter Year", 40);
    JPanel panel = new JPanel();
    JLabel label1;
    String Input1;
    String Input2;
    int month;
    int year;
    int numDays = 0;
  
    public Test() {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      text  = new JTextField("Enter month's #", 40);
      text2.addActionListener(new MyActionListener());
      panel.setPreferredSize(new Dimension(400,800));
      getContentPane().add(panel);
      getContentPane().add(text, "Center");
      getContentPane().add(text2, "Center");
      pack();
      }
  
      public static void main(String[] args) {
      new Test().setVisible(true);
    }
      class MyActionListener implements ActionListener {
          public void actionPerformed(ActionEvent evt) {
       Input1 = text.getText();
       Input2 = text2.getText();
       month = Integer.parseInt(Input1);
       year = Integer.parseInt(Input2);
       math(month, year);
    }
   }
    public void math(int month, int year){
        switch (month) {
        case 1: case 3: case 5:
        case 7: case 8: case 10:
        case 12:
            numDays = 31;
            break;
        case 4: case 6:
        case 9: case 11:
            numDays = 30;
            break;
        case 2:
            if (((year % 4 == 0) &amp;&amp; 
                 !(year % 100 == 0))
                 || (year % 400 == 0))
                numDays = 29;
            else
                numDays = 28;
            break;
        default:
            label1 = new JLabel("Invalid input...");
            getContentPane().add(label1, JLabel.BOTTOM);
            break;
    }
    label1 = new JLabel(Integer.toString(numDays));
    getContentPane().add(label1, JLabel.BOTTOM);
    }
  }
  </code></pre>
  
  <p>I'm sure its probably something I just simply over looked and i hope their is a simple solution! Thanks in advance!</p>