With this code I will have the following window. I created 2 panels and added the mainp one to the frame and the panel to the mainp I did this in order to make window resizing dynamic (so the panel wont resize to the frame) I tried making my default panel size wider so that the text fields and label become wider but panel.setsize doesn't seem to do anything.

// creates the labels
 studId = new JLabel("Student ID");
 studAvg = new JLabel("Student Average");
 studName = new JLabel("Student Name");
 // creates the text fields
 JTextField studIdText = new JTextField();
 JTextField studAvgText = new JTextField();
 JTextField studNameText = new JTextField();
 JPanel mainp = new JPanel();
 JPanel panel = new JPanel();
  panel.setLayout(new GridLayout(3, 2, 2, 2));
            panel.setSize(300, 100);
    // adds to the GridLayout
    panel.add(studId);
    panel.add(studIdText);
    panel.add(studName);
    panel.add(studNameText);
    panel.add(studAvg);
    panel.add(studAvgText);
    mainp.add(panel);
    add(BorderLayout.CENTER,mainp);
    // verifies the textfields
    studIdText.setInputVerifier(new IntVerifier());
    studAvgText.setInputVerifier(new DoubleVerifier());
    setTitle("Student Form");
    setSize(300, 200);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

