Q: "Refresh" a JFrame with setLayout(null) I am trying to get the JFrame to refresh as I want to add a JPanel onto a JFrame after it had been set visible. invalidate() then validate() then repaint() won't work as I don't have a layout manager.
The class:
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Class4 {

    public static final long serialVersionVID = 1L;

    public void mainMethod(int event){

        JFrame f = new JFrame("Love Test");

        if(event == 0){

            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(500,200);
            f.setLayout(null);

            JPanel p = new JPanel(new BorderLayout());
            p.setBounds(150, 0, 350, 75);
            Class3 c3o = new Class3();
            p.add(c3o);
            f.add(p);

            JPanel p2 = new JPanel();
            Class7 c7o = new Class7();
            p2.add(c7o);
            p2.setBounds(0, 75, 500, 40);
            f.add(p2);

            JPanel p3 = new JPanel();
            p3.setBounds(0, 0, 150, 75);
            Class5 c5o = new Class5();
            Dimension d = new Dimension(150,75);
            c5o.setPreferredSize(d);
            p3.setPreferredSize(d);
            p3.add(c5o);
            f.add(p3);

            f.setVisible(true);

        }

        if(event == 5){


            JPanel p4 = new JPanel();
            p4.setBounds(0,120,500,55);
            Class2 c2o = new Class2();
            Dimension d2 = new Dimension(500,55);
            c2o.setPreferredSize(d2);
            p4.setPreferredSize(d2);
            p4.add(c2o);
            f.add(p4);

                f.invalidate();
            f.validate();
            f.repaint();

        }

    }

}

If I were to use a layout manager, how would I use it?
All help will be greatly appreciated. Thanks!
