0

I can't find it anywhere at all, I've tried all obvious names.

I have it working for the ContentPane and the JMenuBar.

This is what I tried last:

ImageEditor ie = new ImageEditor();     
    frame.setJMenuBar(ie.createMenuBar());
    frame.setContentPane(ie.createContentPane());
    frame.setJToolBar(ie.createToolBar());
4

1 回答 1

3

There isn't one. Traditionally the toolbar is added to the outside positions of a container that is using a 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);

I say traditionally, as the last time I used a floating toolbar, it would throw an exception if you tried to add it back to a container that did not use a BorderLayout, this may have being fixed in more recent releases

Take a look at How to use ToolBars for more details

于 2013-10-22T23:23:44.910 回答