-1

I want to add more buttons on JToolbar but I could not add button one on another vertically; rather they are aligning themselves automatically horizontally.

public class Interface 
{
JTable tableT = new JTable();
private JTable table;

  public Interface()
  {
   final JFrame f= new JFrame("Content Provider Generator");
   f.setFont(new Font("Aharoni", Font.BOLD, 12));
   f.setForeground(Color.GRAY);
   f.getContentPane().setBackground(Color.WHITE);

     JToolBar toolBar = new JToolBar();
      f.getContentPane().add(toolBar, BorderLayout.EAST);

  //MenuButton//
      JButton button = new JButton();
button.setIcon(new ImageIcon
        (Interface.class.getResource("/javax/swing/plaf/metal/icons/ocean/menu.gif")));
      toolBar.add(button);   //added to JToolbar

      JPopupMenu popupMenu = new JPopupMenu();
      addPopup(button, popupMenu);

      //Jpopupmenu
      JMenuItem mntmNewMenuItem = new JMenuItem("Table");

      JButton button1 = new JButton();
    button.setIcon(newImageIcon
        (Interface.class.getResource("/javax/swing/plaf/metal/icons/ocean/menu.gif")));
      toolBar.add(button1);
}
}
Roman C
  • 49,761
  • 33
  • 66
  • 176
Asdakamessoy
  • 87
  • 4
  • 12
  • while if turn round the toolbar it will be not a toolbar but a sidebar. – Roman C Apr 27 '13 at 09:52
  • i didnot get what are you trying to tell me ? my problem is that i want to arrange my buttons inside the toolbar vertically one on another .. which im unable to do – Asdakamessoy Apr 27 '13 at 10:04

1 Answers1

4

See JToolBar(orientation).

Creates a new tool bar with the specified orientation. The orientation must be either HORIZONTAL or VERTICAL.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433