Так установите для кнопки размер. Например, вот такой код выдаёт то что нужно

package cg;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
/**
* @author Sergey Mashkov
*/
public class MainFrame extends JFrame {
public MainFrame() throws HeadlessException {
setLayout(new BorderLayout());
setTitle("My toolbar test");
add(createToolbar(), BorderLayout.PAGE_START);
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private static JToolBar createToolbar() {
return new MyToolbarBuilder()
.add("Hello", createEmptyAction())
.add("I", createEmptyAction())
.add("My long long button", createEmptyAction())
.get();
}
private static class MyToolbarBuilder {
private final JToolBar tb = new JToolBar();
private MyToolbarBuilder() {
tb.setBorderPainted(true);
tb.setFloatable(false);
}
public MyToolbarBuilder add(String text, Action action) {
tb.add(createToolbarButton(text, action));
return this;
}
public JToolBar get() {
return tb;
}
}
private static JButton createToolbarButton(String text, Action action) {
JButton btn = new JButton(action);
btn.setText(text);
Dimension size = createSize(32, 32);
btn.setSize(size);
btn.setMinimumSize(size);
btn.setMaximumSize(size);
btn.setPreferredSize(size);
return btn;
}
private static Dimension createSize(int w, int h) {
return new Dimension(w, h);
}
private static Action createEmptyAction() {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
// Do nothing
}
};
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainFrame().setVisible(true);
}
});
}
}