JToolBar: setFloatable(boolean b)
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
public class Main {
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"));
toolBar.addSeparator();
toolBar.add(new JButton("Open"));
frame.add(toolBar, "North");
frame.setSize(300, 200);
frame.setVisible(true);
}
}
Related examples in the same category