Using setFloatable(false) to make a tool bar immovable.
Using setRollover(true) to make the edges of the buttons invisible when mouse pointer is out.
Adding a separator to a tool bar.
Adding a non-button component to a tool bar.
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
public class AddintJToolBarToJFrame {
public static void main(String[] a) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JToolBar toolBar = new JToolBar("Still draggable");
toolBar.setFloatable(false);
toolBar.setRollover(true);
toolBar.add(new JButton("New"));
frame.add(toolBar, "North");
frame.setSize(300, 200);
frame.setVisible(true);
}
}