我有一个具有功能JMenu的Java项目。我试图添加一个工具栏到它,但它没有出现。我确实得到了一些我可以拖动的东西,如果我在菜单栏下点击左右,就会创建一个空白窗口。
protected JToolBar createToolBar(){
JToolBar t1;
t1 = new JToolBar();
JButton test;
test = new JButton("text here");
t1.add(test);
return new JToolBar();
}这段代码也可能是相关的。
protected Container createContentPane(){
// Create the content-pane
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);
// Create the toolbar
JToolBar jt = createToolBar();
contentPane.add(jt, BorderLayout.PAGE_START);
return contentPane;
}我很感谢你的帮助。
发布于 2013-10-28 00:23:25
return new JToolBar();需要的是
return t1;https://stackoverflow.com/questions/19624918
复制相似问题