troubleshooting Question

Turning off a floating JToolBar

Avatar of luckybonanza
luckybonanza asked on
Java
2 Comments1 Solution619 ViewsLast Modified:
I am developing an app that has several tabs in a JTabbedPane.  When a tab is selected I want a tab specific toolbar to be added to a panel 'toolPanel'  and then removed when the tab is deselected.

I have implemented a tablistener that adds and removes the toolbars and this works fine unless the user has dragged the toolbar off the toolPanel.  In that case the toolbar is still removed but the title of its JToolBar window is still there and can only be got rid of by clicking the close-window control.  I can make the toolbar not floatable but I dont want to.

This code is run when a tab is activated
    toolPanel.add(toolBar1);
    toolBar1.setVisible(true);

this code is run when the tab is deactivated
    toolPanel.remove(toolBar1);
    toolBar1.setVisible(false);
    toolPanel.paintAll(toolPanel.getGraphics());

Is there a better way of doing this and how do I get rid of the floating toolbars frame ?

I am using JSE6.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros