Komponent na JPanel nie jest wyświetlany, gdy setLayout (null)

Ktoś może powiedzieć, dlaczego combobox nie jest wyświetlany? Mam kontrolera:

public class TestController extends JPanel {

TestView cgView;

public TestController() 
{

    setLayout(null);

    cgView=new TestView();

    add(cgView);

}
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
             JFrame fr = new JFrame("testt");
                fr.setSize(1200,1000);
                fr.setResizable(false);

                TestController cgc=new TestController();
                fr.setBackground(Color.white);
                fr.setVisible(true);

                fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                fr.add(cgc);

         }
        });
    }


}

I widok

public class TestView extends JPanel{
    private static final long serialVersionUID = 1L;

    public JComboBox<String> comboBox; 

    public TestView() {

          comboBox= new JComboBox<>(new String[] {"option1", "option2" });
          comboBox.setBounds(100,500, 100, 20);
          add(comboBox);

    }
}

Z powodusetLayout (null) w kontrolerze testowym nie widzę comboBox. Jeśli dodamdodaj (cgView.comboBox) do mojego TestContoller (), tak aby wyglądał tak:

public TestController() 
    {

        setLayout(null);

        cgView=new TestView();

        add(cgView);
        add(cgView.comboBox);

    }

Niż to widzę. Czy ktoś może powiedzieć dlaczego?

Więc moim rozwiązaniem jest zawsze dodawać komponenty w TestController lub przekazać TestController jako atrybut do TestView (tak w TestView () dodałbym je tak jak to.parentPanel.add (comboBox). Czy jest jakieś inne rozwiązanie?

questionAnswers(1)

yourAnswerToTheQuestion