They're on top of eachother because you're putting them all in the same two places - namely BorderLayout.EAST
and BorderLayout.WEST
.
You can achieve your desired effect without using a BorderLayout
but instead using JToolBar
's default layout.
add(tab);
// add other elements you want on the left side
add(Box.createHorizontalGlue());
add(Screenshot);
add(UserKeyInput);
add(UserMouseInput);
//everything added after you place the HorizontalGlue will appear on the right side
EDIT (based on your comment):
Create a new JPanel and add it to the toolbar before the glue:
JPanel leftPanel = new JPanel();
add(leftPanel);
add(Box.createHorizontalGlue());
add(Screenshot);
add(UserKeyInput);
add(UserMouseInput);
Then have your addButtonLeft()
method add new buttons to the panel, rather than directly to the toolbar.