JDesktopPanel question

hi, i'm on develop a MDI application using swing but i have a question, my JInternalFrame listening on Active event to change toolbar and menu on JDesktopPanel, but i don't know how to get JDesktopPanel instance from JInternalFrame instance to change its ToolBar, which method to do that? thanks experts : )
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

khacduystAuthor Commented:
thanks for quick response, but i need a little help from you,

the toolbar in JDesktopPanel have some child toolbar in it, when a JinternalFrame is selected it'll add a child toolbar in main toolbar of JDesktopPanel and when it deactive it will remove that toolbar out of main toolbar, when it deactive i call remove method on main toolbar to remove child toolbar, but when that JInternalFrame  active again it cannot add that toolbar to main toolbar, is when we call remove method it'll remove that child toolbar forever? and we never add it to main toolbar again? if yes is how can i do to make main toolbar in JDesktopPanel dynamic depending on which JInternalFrame active, thanks
khacduystAuthor Commented:
here my code on JIntenalFrame:

    public void internalFrameActivated(InternalFrameEvent e) {
        BaseDesktopPane jdp=((BaseDesktopPane)this.getParent());
        JScrollableDesktopPane  jsp= (JScrollableDesktopPane)jdp.getJScrollDesktopPanel();
        tb1=new JToolBar();        
        JButton bt=new JButton("aaaaaas");

    public void internalFrameDeactivated(InternalFrameEvent e) {
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

not sure i undertstand, what exactly is the problem?
khacduystAuthor Commented:
the problem is:

how can i create a dynamic toolbar that will change depending on which JInternal is selected, i do that by code i gave u above, when it active it add a toolbar(tb1) to main toolbar(tb) when it deactive it remove that toolbar(tb1) out of main toolbar(tb), but when it active again it can't add child toolbar(tb1) again , my question is : is when we call tb.remove(tb1); we can't add that toolbar again? and if yes, how can i create a dynamic toolbar? thanks
> but when it active again it can't add child toolbar(tb1) again ,

why not?

> is when we call tb.remove(tb1); we can't add that toolbar again?

Yes you can use it again.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
you could ctreate tb1 in your frame constructor
and add//remove it in your listsener
khacduystAuthor Commented:
i have a mistake in my code : ) , thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.