I am arranging components on JFrame, but doesn’t seem to work correctly. I use GridBagLayout, but wasn’t successful. I am trying to center "checkoutBtn" and "checkinBtn"

If you want to see exact illustratoin follow the below link.

http://webdev.apl.jhu.edu/%7Emed/fall03/homework/04LibrarySwing.html
My code is the following:

//set library panel

constraints.weightx = 1000;

constraints.weighty = 1;

constraints.fill = GridBagConstraints.BOTH;

addComponent(libraryPanel,

0, 0, 5, 6);

//set checkoutBtn

constraints.weightx = 0;

constraints.weighty = 0;

constraints.fill = GridBagConstraints.NONE;

addComponent(checkoutBtn, 5, 2, 1, 1);

//set check in button

constraints.weightx = 0;

constraints.weighty = 0;

constraints.fill = GridBagConstraints.CENTER;

addComponent(checkinBtn, 5, 3, 1, 1);

//set checkoutlog Panel

constraints.weightx = 1000;

constraints.weighty = 1;

constraints.fill = GridBagConstraints.BOTH;

addComponent(checkoutlogPanel, 6, 0, 1, 6);

…

…

private void addComponent(Component component,

int column, int row, int width, int height) {

// set gridx and gridy

constraints.gridx = column;

constraints.gridy = row;

// set gridwidth and gridheight

constraints.gridwidth = width;

constraints.gridheight = height;

// set constraints and add component

layout.setConstraints(component, constraints);

contentPane.add(component, constraints);

}