What is the right way to change the active JInternalFrame for and MDI app?

I am working on my own implementation of the window menu. The action that is triggered when a customer chooses a window to activate from the list in the menu is not behaving as I expected. The code I wrote (below) switches frames correctly but the caption bar never gets updated and if you restore a frame from an icon the frame is not correctly activated, there is even a restore button which if you push fixes things up and the frame then behaves normally     if (frameToActivate.isIcon ())  {
          //  Restore from icon
          desktopPane().getDesktopManager().deiconifyFrame (frameToActivate);
     desktopPane().getDesktopManager().activateFrame (frameToActivate);
     desktopPane().setSelectedFrame (frameToActivate);I did a search of the web and found a tip on JavaWorld (http://www.javaworld.com/javaworld/jw-05-2001/jw-0525-mdi.html) which led me to try doing this from a different angle - the JInternalFrame's point of view. This code works     try {
          if (frameToActivate.isIcon ())  {
               //  Restore from icon
               frameToActivate.setIcon (false);
          frameToActivate.moveToFront();
          frameToActivate.setSelected (true);
     } catch (PropertyVetoException error) {
          error.printStackTrace();
     }My question is why does the desktop based approach not work? If methods exist that appear to let you restore and switch between frames why are the ineffective? Am I missing something obvious that I should be doing?
If using the JInternalFrame methods is the right way to go then I will It just seems like if the DesktopManager has methods that advertise that is supports managing the active frame then they should work. Before I ignore them I want to check with you to see if there is a right way to use them.
Ian

So, this is another batch of duke dollars I cannot assign - since I solved my own problem:-)
I had an epiphany and tried setting break points to see what code was executed when you click on an inactive frame. From that I determined that DefaultDesktopManager.activateFrame, as implemented, does not activate the frame but acknowledges the activation of a frame and does a small amount of bookeeping work for the DesktopManager. So, the solution is the code I wrote to switch focus using the JInternalFrame's methods. Since I did not want to have to write those nine lines of code in the couple of places I want to programmatically switch the active frame I added a get/setActiveFrame method to my JDesktopPane derivative. In case others face this problem here is the code (warning I have not yet setup building the JavaDocs for this project so I cannot vouch for the validity of the JavaDoc, but the code does work):/**
* Bring frameToActivate to the front (restoring from icon if neccessary) and make it the
* selected frame.  This method does all the things required to switch the active frame for
* an MDI application unlike: @link JDesktopPane.setSelectedFrame, which does not change the
* focus; @link javax.swing.DefaultDesktopManager.activateFrame which does not correctly
* handle iconified frames or switch the focus properly; and
* @link javax.swing.JInternalFramesetSelected which also does not handle iconified frames.
* @param frameToActivate the frame to bring to the front and become the active window
* @throws IllegalArgumentException
public void setActiveFrame (JInternalFrame frameToActivate) throws IllegalArgumentException  {
    if (frameToActivate == null)
        throw new IllegalArgumentException ("setActiveFrame a frame must be passed a non null valie.");
    try {
        if (frameToActivate.isIcon ())  {
            //  Restore from icon
            frameToActivate.setIcon (false);
        frameToActivate.moveToFront();
        frameToActivate.setSelected (true);
    } catch (PropertyVetoException error) {
* This method returns the currently active frame.  This method returns the same frame
* as <code>getSelectedFrame</code> and is provided for symetry for <code>setActiveFrame</code>. 
* @return the currently active frame
* @see LDesktopPane.setActiveFrame
* @see javax.swing.JDesktopPane.getSelectedFrame
public JInternalFrame getActiveFrame ()  {
    return getSelectedFrame ();
}IL

Similar Messages

  • What is the conditional operator for AND, OR .....?

    what is the conditional operator for AND, OR .....? in ABAP language...
    AND, OR .. & is not accepting or recognising.
    Is these feature available in abap ??? if yes, how to use?
    thanks...
    shiva

    Hi,
    Conditional operator for AND and OR are same AND and OR.
    A logical expression consists of comparisons (see expressions 1 to 4 below) and/or selection criteria checks (expression 5) using the operators AND, OR and NOT , as well as the parentheses " (" and ")".
    The individual operators, parentheses, values and fields must be separated by blanks:
    Incorrect:
    f1 = f2 AND (f3 = f4).
    Correct:
    f1 = f2 AND ( f3 = f4 ).
    NOT takes priority over AND, while AND in turn takes priority over OR:
         NOT f1 = f2 OR f3 = f4 AND f5 = f6
    thus corresponds to
         ( NOT ( f1 = f2 ) ) OR ( f3 = f4 AND f5 = f6 )
    The selection criteria comparisons or checks are processed from left to right. If evaluation of a comparison or check proves part of an expression to be true or false, the remaining comparisons or checks in the expression are not performed.
    All data objects that can be converted among each other can be used as operands for logical expressions.
    Check if u are using the AND or OR operator this way.
    IF f1 AND f2.
    ENDIF.
    In this case it will throw error. Here it act as relational operator.
    Regards,
    Prakash

  • Update my app. What is the correct procedure for updating an app/folio?

    I designed a folio in Indesign CS6 and created an app of the folio in adobe dps and succesfully uploaded it to the app store. Now I want to update my app. What is the correct procedure for updating an app/folio?

    no, just update your content and recreate the Single Edition App. Your certificate should still be valid so there is not need to recreate these.
    ... your App ID absolutely need to be the exact same one you used for the first version if you want to make sure this is an update.

  • What is the activation code for InDesign CS5?

    What is the activation code for InDesign CS5?

    We've recently upgraded to CS5 and they are requiring an activation/authorization to continue using the program.

  • What are the F keys for and what are the insert and delete line shortcuts?

    I have always had a full keyboard and I'm really missing a few shortcuts I previously had that I used mostly in Quickbooks...mainly using the Control insert combination for inserting a line in General Journal and also the Control delete for deleting a line. Is this just an issue with Quickbooks on a Mac? I hate to say it, but during a period of insanity and persuasion by my accountant, I...GASP, went to a PC from a Mac and now I'm finally back in the family. I've forgotten a lot of what I'd learned in the last several years. Do the F keys have these capabilities or is there some other way? Thank you for any assistance.

    Look carefully at the F keys you will see that F1 and F2 will darken and Brighten yur screen F 10 11 and 12 will Mute turn down and turn up your sound.F3 will minimise the screen F4 goes to all your Applications installed.
    You need to fool around and see what they all do to help minimize work
    Cheers
    Don
    http://support.apple.com/kb/HT1343
    http://macmost.com/mfm/mastering-keyboard-shortcuts.html

  • What is the Category field for and how do I edit it?

    In the iTunes music list, there is a category field. However, I do not see it in the get info window. Not surprisingly, although the category field shows in my iTunes music list, none of my songs have anything entered for the category. What is this field for and how do I edit it? Thanks.

    The only items I have that show a category are some iTunes U downloads.
    You can see a list of iTunes U category and subcategory codes and associated names here: http://deimos.apple.com/rsrc/doc/iTunesUAdministrationGuide/iTunesUintheiTunesSt ore/chapter13_section3.html

  • What is the activation code for netflix?

    trying to activate my apple tv on my netflix account. netflix is asking for an activation code. what is it? where do i find it?

    There is no activiation code. You just log in to your account on the apple tv

  • What is the activation key for Windows 8.1 pro with media center build 9600

    Send me through mail.

    The specs indicate that the computer originally had FreeDos on it.
    Did you purchase a full retail version of Windows 8.1 to install on it?  If you did your invoice or documentation should have the key.
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

  • What's the difference between CS6 and CC apps?

    I am confused. I am running CS6 and having problems with Adobe Exchange in Illustrator - works fine in PS and INDD.
    For some reason Illustrator cannot find an internet connection. Tried ALL of the prescribed troubleshooting but it's still broke. Is there any advantage to running CC versions of the apps?

    iPad apps are designed specifically for the iPad and will not run on the iPhone or iPod Touch. iPhone/iPod apps will run on the iPad, but will only take up an iPhone sized portion of the iPad screen (though you get a 2x button which effectively doubles each pixel in both directions so may appear pixelated). There are also 'universal' apps (which have a '+' symbol against them in the store) which have processing in them to recognise the device that they are on and will tailor the display accordingly (so will make use of the iPad's larger screen).

  • What is the best PDF reading and organizing app?

    How to chose from the myriad list of apps.

    https://itunes.apple.com/us/app/adobe-reader/id469337564?mt=8
    Thats the Adobe Reader App that I use with my iPad.

  • What are the minimum requirements for compiling apps for iOS7?

    Hi, guys.
    I currently have a computer with XCode 4.6.3 and Mac OS X (v10.7.5).
    Is this enough to compile apps for the AppStore for iOS 7?
    What are the minimum requirements for compiling these apps? XCode version or both XCode and OS X versions?
    Thanks in advance,

    OK, actually this site has a better explanation of the prerequisites:
    http://readwrite.com/2013/06/12/everything-you-need-to-know-to-get-started-with- ios-7-development#awesm=~opgY8n30iuR9oM

  • What is the best practice for changing view states?

    I have a component with two Pie Charts that display
    percentages at two specific dates (think start and end values).
    But, I have three views: Start Value only, End Value only, or show
    Both. I am using a ToggleButtonBar to control the display. What is
    the best practice for changing this kind of view state? Right now
    (since this code was inherited), the view states are changed in an
    ActionScript function which sets the visible and includeInLayout
    properties on each Pie Chart based on the selectedIndex of the
    ToggleButtonBar, but, this just doesn't seem like the best way to
    do this - not very dynamic. I'd like to be able to change the state
    based on the name of the selectedItem, in case the order of the
    ToggleButtons changes, and since I am storing the name of the
    selectedItem for future reference.
    Would using States be better? If so, what would be the best
    way to implement this?
    Thanks.

    I would stick with non-states, as I have always heard that
    states are more for smaller components that need to change under
    certain conditions, like a login screen that changes if the user
    needs to register.
    That said, if the UI of what you are dealing with is not
    overly complex, and if it will not become overly complex, maybe
    states is the way to go.
    Looking at your code, I don't think you'll save much in terms
    of lines of code.

  • What are the config steps for contract mass change and quota arrangement?

    Hi friends
    what are the config steps for contract mass change and quota arrangement?
    Regards
    Raj Kumar

    Process Flow
    The mass change process consists of four steps. You navigate between these steps by choosing the Next and Back buttons located at the bottom right-hand corner of the screens.
           1.      Search for contracts
    You search for and select the contracts or the contract hierarchy that you want to change.
    Contracts that have the status Closed cannot be changed.
           2.      Define mass changes
    You specify the changes you want to make.
    You make changes at header data level and at item data level by choosing the relevant change methods. A green tick appears next to each change parameter so that you can see where changes are already active.
    Once you enter this step, the documents you have selected to be changed are locked so that other users cannot make changes to them until you are finished with this process.
           3.      Simulate mass changes
    Here you can perform a trial run of your mass changes. This simulation step is optional.
    We recommend that you perform this step so that you can check how the change methods you have chosen will be processed by the system.
    You receive status messages about the change methods for each contract and can quickly see whether any errors arise in connection with the proposed changes at this stage. From this step, it is easier for you to go back and correct the error than after applying the changes.
    Background processing
    The system processes the changes in the background.
    If there are a large number of contracts to be processed, this step could take some time to complete. In this case, you can leave the transaction so that you can, for example, carry out other tasks in the meantime.
    The system sends you an e-mail once the simulation step is complete. The e-mail contains a link to the relevant screen in the application so that you can return to it when it is convenient for you to do so. If you have left the SRM application, you can only return via this link.
    Here you can see the status of the changes and, if necessary, you can correct any errors by going back to the Define mass changes step.
    The messages that you receive in the simulation step are not confirmation that a change has been performed. They simulate the messages you get after you apply the changes. You must complete the final step of the mass change process and apply the changes before they take effect.
           4.      Carry out mass changes
    Here you apply the changes to the contracts.
    You cannot reverse this step, which is why we advise you to perform the simulation step beforehand.

  • HT4910 documents edited on iphone, ipad, & mac   what is the order of creation and editing and must each change be manually initiated to update the icloud

    documents edited on iphone, ipad, & mac   what is the order of creation and editing and must each change be manually initiated to update the icloud?

    No idea what you mean by the firsy part of your question.
    Documents edited on the Mac need manually uloading to iCloud at iCloud.com,documents edited on the mobile devices are updated automatically.

  • What is the constant name for Change layout Button in ALV Grid ABAP Objects

    Dear All,
    I have one query please help me.
    what is the constant name for Change layout Button in ALV Grid ABAP Objects.
    With Rgds,
    Babu

    Halo Vinod,
    The consant name is cl_gui_alv_grid=>mc_fc_current_variant.
    Regards
    Arshad

Maybe you are looking for