Hello. I have an application running on JTabbedPane which consists of two
JPanels. When the application is first launched, it shows components on
both tabs until I click on one of the tabs, which then displays only the
components on the tab.

Each tab consists of it's own GridBagLayout and components are added to it.

The code is quite long but just to give you the idea,

public void init()
resize(660, 600);
setLayout(new GridLayout());

JTabbedPane mTabbedPane = new JTabbedPane();
mTabbedPane.addTab("Recording Mode",recordPanel());
mTabbedPane.addTab("Playing Mode",playPanel());

public JPanel recordPanel()
JPanel recPanel = new JPanel(false);
GridBagLayout recGridBag = new GridBagLayout();
GridBagConstraints recConstraints = new GridBagConstraints();
Insets mInsets = new Insets(10,30,10,30);
*---------components added to the recGridBag---omitted------*

public JPanel playPanel()
JPanel playPanel = new JPanel(false);
GridBagLayout playGridBag = new GridBagLayout();
GridBagConstraints playConstraints = new GridBagConstraints();

*---------components added to the playGridBag---omitted------*

Thank you.