我有一些Jpanel中的项目,然后推到顶部并用作基本搜索引擎的工具栏。我有一个问题,由于没有足够的空间,我的最后一个组合框没有显示。但是,左侧有很多空的空间,我需要一切来移动填充JPanel,然后才能显示。所以我的问题是如何让这些物品从最左侧开始并向右转,谢谢。填充JPanel
//Labels for combo boxes
JLabel Bookmarklbl = new JLabel("Bookmarks:");
JLabel Historylbl = new JLabel("History:");
FlowLayout flowLayout = new FlowLayout();
MainBrowser.toolBar.setLayout(flowLayout);
//Adding items to Panel
MainBrowser.toolBar.add(Bookmarklbl);
MainBrowser.toolBar.add(BookmarkList);
MainBrowser.toolBar.add(bookmarkbtn);
MainBrowser.toolBar.add(back);
MainBrowser.toolBar.add(forward);
MainBrowser.toolBar.add(MainBrowser.addressbar);
MainBrowser.toolBar.add(home);
MainBrowser.toolBar.add(reload);
MainBrowser.toolBar.add(Historylbl);
MainBrowser.toolBar.add(historyList);
//Set the things added from left to right
MainBrowser.main.setComponentOrientation(
ComponentOrientation.LEFT_TO_RIGHT);
//Add Panel to main frame
MainBrowser.main.add(MainBrowser.toolBar,BorderLayout.NORTH);
酒吧的样子:http://postimg.org/image/l314iw6eh/
什么是工具栏在这里,它是JPanel? – swapnil7
@ swapnil7 yep,它在不同的类中声明 – Corzuu