Try this one
JPanel parentPanel_top = new JPanel(new GridLayout(1, 2));
...
JPanel topleftpanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
parentPanel_top.add(topleftpanel);
...
JPanel toprightpanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5));
parentPanel_top.add(toprightpanel);
Note : remove extra setLayout()
set for above JPanel
s.