How can I pass a JPanel through different methods:

I am doing it like this:

in the main panel method:
Code:
 mainPanel.add(createRightPanel(), BorderLayout.EAST);
and in the method createRightPanel() I am returning like this:

Code:
  return createRightPanel();
but it doesn't work.