-1

我想添加更多按钮,JToolbar但无法垂直添加一个按钮;相反,它们会自动水平对齐。

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);
}
}
4

1 回答 1

4

JToolBar(orientation)

使用指定的orientation. 方向必须是HORIZONTALVERTICAL

于 2013-04-27T10:09:35.790 回答