I am having trouble getting a JSeparator to show up inside of a JToolBar. My toolbar is created as follows :
public class ToolBar extends JToolBar {
super();
FlowLayout layout = new FlowLayout(FlowLayout.LEFT, 10, 5);
setLayout(layout);
add(new JButton("Button 1"));
addSeparator();
add(new JButton("Button 2"));
add(new JButton("Button 3"));
addSeparator();
// Show
setVisible(true);
setFloatable(false);
}
Any thoughts would be really appreciated, I have been trying to get this to work for way too long now >(
Trying your code there, when I call the addSeparator()
method it creates a space between the buttons but no visible separation line.
But if I change the method to addSeparator(new Dimension(20,20))
it then creates the visible separation line.
The problem could be that the default look and feel creates a separator of height 1 so you would be unable to see it.
I am running it on Mac OSX.