Turning off a floating JToolBar

Posted on 2007-07-19
Last Modified: 2012-06-22
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

this code is run when the tab is deactivated

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

I am using JSE6.

Question by:luckybonanza
    LVL 92

    Expert Comment


    LVL 23

    Accepted Solution

    If the toolbar is tab specific i think its better to disable the floating of the toolbar

          toolbar .setFloatable(false) ;

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now