Java tutorial
import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JFrame; import javax.swing.JToggleButton; import javax.swing.JToolBar; public class ToolBarTest { public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JToolBar bar; bar = new JToolBar(); JToggleButton jb; for (int i = 0; i < 8; i++) { jb = new JToggleButton("" + i); bar.add(jb); if (i == 5) { bar.addSeparator(); } } contentPane.add(bar, BorderLayout.NORTH); frame.setSize(300, 300); frame.show(); } }