Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JDesktopPanel question

Posted on 2006-03-30
8
Medium Priority
?
333 Views
Last Modified: 2012-08-14
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 : )
0
Comment
Question by:khacduyst
  • 4
  • 4
8 Comments
 

Author Comment

by:khacduyst
ID: 16339310
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
0
 

Author Comment

by:khacduyst
ID: 16339325
here my code on JIntenalFrame:


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

    public void internalFrameDeactivated(InternalFrameEvent e) {
        tb.remove(tb1);
        tb.repaint();
    }
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 16339358
not sure i undertstand, what exactly is the problem?
0
 

Author Comment

by:khacduyst
ID: 16339382
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
0
 
LVL 92

Accepted Solution

by:
objects earned 1500 total points
ID: 16339394
> 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.
0
 
LVL 92

Expert Comment

by:objects
ID: 16339447
you could ctreate tb1 in your frame constructor
and add//remove it in your listsener
0
 

Author Comment

by:khacduyst
ID: 16339464
i have a mistake in my code : ) , thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

577 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