我根本找不到它,我已经尝试了所有明显的名称。
我让它适用于 ContentPane 和 JMenuBar。
这是我最后尝试的:
ImageEditor ie = new ImageEditor();
frame.setJMenuBar(ie.createMenuBar());
frame.setContentPane(ie.createContentPane());
frame.setJToolBar(ie.createToolBar());
最佳答案
没有一个。传统上,工具栏被添加到使用 BorderLayout
...
frame.setLayout(new BorderLayout()); // This is actually the default layout anyway
frame.setJMenuBar(ie.createMenuBar());
frame.getContentPane().add(ie.createContentPane());
frame.getContentPane().add(ie.createToolBar(), BorderLayout.NORTH);
我传统上说,就像我上次使用 float 工具栏一样,如果您尝试将其添加回不使用 BorderLayout
的容器,它会抛出异常,这可能是在最近的版本中已修复
看看How to use ToolBars了解更多详情
关于java - JToolBar 等价于frame.setJMenuBar(ie.createMenuBar()); 的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19530059/