You need to create GridBagConstraints and define anchor (among others like x_weight) to center in GridBagLayout
Then add the component to the layout like this
GridBagLayout layout = new GridBagLayout();
GridBagConstraints cons = new GridBagConstraints();
//set the constraints properties
layout.addLayoutComponent(JProgressBar, cons);
then
setLayout(layout)