سؤال

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?

هل كانت مفيدة؟

المحلول

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top