Question

When you add a JToolBar to a component, you can drag it out and it create a new floating window while the parent component is also there. How can I make JToolBar show this floating window automatically with the parent invisible?

Était-ce utile?

La solution

You can override javax.swing.plaf.basic.BasicToolBarUI and set its parent to the instance of a container (JDialog, JFrame). This should create a floating toolbar by default.

You can set the BasicToolbarUI like below:

ui = new BasicToolBarUI();
toolBar = new JToolBar();
toolBar.setUI(ui);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top