将JMenuBar与JToolbar放到JPanel中

系统有很多jPanel,每个Jpanel都有不同的JMenubar,为将JMenuBar与JToolbar放到JPanel中可采用如下方法:

public class BasicGraphEditor extends JPanel
...
protected void installToolAndMenuBar() {
		JPanel jp = new JPanel();
		jp.setLayout(new BorderLayout());
		jp.add(new EditorToolBar(this, JToolBar.HORIZONTAL), BorderLayout.CENTER);
		jp.add(new EditorMenuBar(this), BorderLayout.NORTH);
		add(jp ,BorderLayout.NORTH);
	}


发布了34 篇原创文章 · 获赞 9 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/tianyatest/article/details/47057677