Getting new sizes immediately after calilng setVisible

How can I get the new sizes after hiding/showing a panel? I have a left and right panels, and a thin vertical bar in between that will alternatively collapse/expand the left panel whenever a user click on it. There's a PDF document in the right panel and I want it to do a "fit to page" calculation immediately after the left panel hides/shows. If I do it without the invokeLater() method, the sizes after setVisible() doesn't change and then the sizes will always be one click "behind". Like for example, when I first click on the vertical bar, the left panel collapses and the PDF page size stays the same. After the second click on the bar, the left panel expands (right panel gets smaller) and the PDF page gets bigger and fits the previous size of the right panel when the left panel was collapsed. It's like the program is recording the previous sizes, not new ones. I understand that there's an event dispatching thread and the sizes wont be updated until after the layout calculation has been done in the thread. How can I make it to do the layout immediately after calling setVisible()? I can bear with this, but there's a noticeable "fit to page" lag after the left panel changes its visibility. Is there a better way to do this?
Here's the snippet of the code:
This is where the visibility changes and where it calls the "fit to page" (fitPdfToViewport) method.
public void toggleMenuButtonVisibility(){
     final PdfViewerPanel viewPanel = efbFrame.getPdfViewerPanel();
     this.menuContentPanel.setVisible(this.hidden);
     this.hidden = !hidden;
     if(viewPanel.isFitToPage){
//          viewPanel.validate();
//          this.menuContentPanel.validate();
          Runnable blah = new Runnable(){
               public void run(){
                    viewPanel.fitPdfToViewport();
          SwingUtilities.invokeLater(blah);
}This is the "fit to page" method:
public void fitPdfToViewport(){
     this.pdfController.setZoom(1.0f);     //reset the PDF dimension
     Dimension viewDim = this.documentPanel.getSize();
     Dimension pdfDim = this.pdfController.getDocumentViewSize();
     if(pdfDim != null && viewDim != null){
          float vRatio = (float)viewDim.height / pdfDim.height;
          float hRatio = (float)viewDim.width / pdfDim.width;
          float ratio = (vRatio > hRatio) ? hRatio : vRatio;
          this.pdfController.setMinumumZoom(ratio);
          this.pdfController.setZoom(ratio);
}Thanks in advance, guys!

Add a ComponentListener to your panel containing the PDF. On componentResize() you add your code.

Similar Messages

  • After updating my I pad, I have problems with getting new apps. After filling in my Apple Id, I fill in my  3 secret questions. But than I get à Message that this session had to break of, without results.

    Alter updating my IPad, I have problems getting new apps. After filling  in my Apple Id, and answer my 3secret questions, I get THE answer that this session had to be ended without results.

    Wow ! I got it running again ! :-)
    I called support and got helped by a very friendly guy:
    We tried serveral things, what worked for me was to reset my cookies:
    - Close all apps by doubleclicking the "home" button - you see all running apps in the lower part of the screen. Then click an hold the first icon until it starts "shaking". Klick the small minus, proceed like that until the row is empty. 
    - Go in to the control center (don't know what it's called in english, in swedish it's "Inställningar")
    - Klick the tab "Safari"
    - Klick on Clear cookies and data ("rensa cookies och data")
    - Close the control center and start App store
    If you now try to download an app you still get the request for the three safety-questions, but when filling them in it works and you can proceed after that. The questions will not turn upp again afterwards...
    Good Luck !
    Other things we tried was:
    - disconnecting the wifi and restarting it
    - log out from app-store (in control center, tab "itunes and appstore")

  • Updating ALV Screen after getting New Out put  (  After BACK no old o/p )

    Hi All
    I have got a ALV output with check box in it and a post button on application toolbar. If I am clicking a row and clicking post button I am able to get new alv output wherein I am removing clicked row from newer output screen. ( I am doing by reexecuting REUSE_ALV_GRID_DISPLAY).
    However if I press BACK button on the output I am again going back to old screen where I get old row which I had clicked. Is there any way from where I'll be able to skip these screens ? Or is there any alternate way of dealing this ?
    Regards
    Amol

    Hi amol,
    1. on double-clicking the row,
      it will get deleted.
    2. On pressing back, it will come back to program.
    3. just copy paste.
    4.
    REPORT abc.
    TYPE-POOLS : slis.
    Data
    DATA : ITAB LIKE T001 OCCURS 0 WITH HEADER LINE.
    DATA : alvfc TYPE slis_t_fieldcat_alv.
    Select Data
    SELECT * FROM t001 INTO TABLE itab.
    *------- Field Catalogue
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
        i_program_name         = sy-repid
        i_internal_tabname     = 'ITAB'
        i_inclname             = sy-repid
      CHANGING
        ct_fieldcat            = alvfc
      EXCEPTIONS
        inconsistent_interface = 1
        program_error          = 2
        OTHERS                 = 3.
    Display
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        it_fieldcat             = alvfc
        i_callback_program      = sy-repid "<-------Important
        i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
      TABLES
        t_outtab                = itab
      EXCEPTIONS
        program_error           = 1
        OTHERS                  = 2.
    CALL BACK FORM
    FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
    slis_selfield.
      <b>delete itab index whatrow-tabindex.
      whatrow-REFRESH = 'X'.</b>
    ENDFORM. "ITAB_user_command
    regards,
    amit m.

  • I cannot get new E-mail after lion 10.7.5

    I have been using Lion 10.7.2 and updated to 10.7.5 and now I cannot receive new E-mail, Can send ok

    Check your SMTP settings in Mail. Make sure your email account you use is selected. Mail / Preferences / Accounts. Click the drop down for Outgoing Mail Server (SMTP) and select Edit SMTP Server List. Make sure the server name is correct under the Account Information tab. Click the Advanced tab and make sure your Authentication, User Name and Password are correct.
    I know for me after updating to 10.7.5, I had to reenter my account password for SMTP.

  • Long delay getting new mail

    I am experiencing a long delay in Mail getting new mail. Here's what happens:
    1. on launching Mail, it gets new mail immediately, so I know my account settings are good.
    2. once Mail is running, there is a long delay in updating new incoming mail -- can be hours. I have Mail set to check every five minutes. Also, I can manually click on Get Mail and I get a No New Mail beep even when there is new mail (see next point).
    3. If I use webmail to access my account, I can see new mail sitting in my In Box.
    4. if I quit and relaunch Mail, the new mail shows up.
    I have an IMAP account which has worked well for years. This delayed behaviour started a few months ago when I was running Leopard. I posted a question but never got an answer that worked. Now I have just upgraded to Snow Leopard 10.6.4, and hoped Mail would correct itself with the upgrade. It didn't.
    I was once advised that it might have something to do with the Preferences > Accounts > Advanced > "Use IDLE command if the server supports it" setting. However, this preference is ticked and greyed out so I can't change it. (The advice was to turn it on or off and see if that was a fix).
    I am running on an iMac 24" Core 2 duo (early 2008 model). After the Snow Leopard upgrade I repaired permissions and ran all the chron scripts. So my system should be pretty good.
    I would be grateful for any help. I have clients call and say "I just sent you an email..." and I appear dumb because I have to go to webmail to get it right away.

    It's getting better. I used Other to setup my mail acc via MfE, by tricking it to a non uniform mail. That worked, I changed it back to googlemail and guess what?! Next time I boot the phone, the MfE is gone. but it still registers in the background so I can't create a new one. Configuration Tool 6.3 does see it but cannot overwrite it. PixiEnables package and its font nonsens severly screw with PopUpClock, Screensaver and SleepingScreen memory boundaries so those three crash. Thanks for nothing MS apps -.-

  • AFS : Add new size grid to the production order

    Hi,
    My companies requirement is, add new size grid for the partially confirmed production order. This production order is created without BOM and components are attached at the point of creation and based on the routings the component allocation also done.
    Can anyone help me to solve the issue. Coz for the new size the component requirement is not changed accordingly. Even PP master data read also not possible coz order has been partially confirmed.

    Hi VIshal,
    In my case there is no master data. Operations and components are manintained in order creation. I have two requirements.
    1. Change the order size & qty before the execution of order.
    2. Add new size grid after some operations are confirmed in the order.
    In the both cases, the component requirement is not changed accordingly.
    But in 1st case if only qty change, component requirement is adjusted accordingly.
    Edited by: Jayakody Arachchige Hansika Kamangi on Nov 3, 2009 1:24 PM
    Edited by: Jayakody Arachchige Hansika Kamangi on Nov 3, 2009 1:25 PM

  • Being signed out immediately after singing in.

    Hello,
    i am getting signed out immediately after siging in. I have tried using my phone to sign in, but sadly its logs me off too.

    http://heartbeat.skype.com/2014/09/i_keep_getting_​​​​​​​​​​​​​​signed_out.html
    Open your Skype account settings page:
    https://secure.skype.com/portal/account/settings
    If your Skype account is linked with Microsoft account, then try to unlink them.
    https://support.skype.com/en/faq/FA12211/how-do-i-unlink-my-skype-and-microsoft-or-facebook-accounts

  • HT4157 I have a cellular data account on my iPad. Almost immediately after I signed up, my e-mail was hacked and had to be cancelled. I cannot get into my AT&T cellular data account now to change the billing and account to my new e-mail. Please help.

    I have a cellular data account on my iPad. Almost immediately after I signed up, my e-mail was hacked and had to be cancelled. I cannot get into my AT&amp;T cellular data account now to change the billing and account to my new e-mail. Please help.

    According to the AT&T Wireless web site, you can manage your iPad data plan either from the iPad, or by using a web browser:
    From the website
    Log in to your account at att.com/iPadlanding using the email address and password you used during activation.
    Your account information will display. Select the desired account change option then tap Next.
    Read the Terms of Service, and then tap Accept.
    Review the Payment Summary to ensure the details are correct. Use the Back button if changes are required, otherwise tap Submit.
    Read the Confirmation message then tap OK.

  • After 6 tries to load Photoshop CS6 on my new laptop, I keep getting the following message after I enter my valid serial number: "Serial number you provided is valid but a qualifying product could not be found on this computer."  What I'm, trying to do is

    After 6 tries to load Photoshop CS6 on my new laptop, I keep getting the following message after I enter my valid serial number: "Serial number you provided is valid but a qualifying product could not be found on this computer."  What I'm, trying to do is download the qualifying product which I purchased just a year ago?  Any help will be greatly appreciated.

    I contacted Adobe support Chat and they confirmed the serial number and gave me a response code number to enter. Once that was entered the product downloaded immediately. The whole process took 10 minutes.  Thank you for your response. I'm all good now.

  • "ipod cannot update - file not found" after getting new ipod

    i had my ipod replaced today at the apple store because of a bad HD. Seems like the one they gave me was brand new...anyway after following the restore/charge directions, i went to go plug it into my dock and Itunes is telling me it can't update the ipod because the file is missing. i definitely have the latest update installer, and i even tested playlist syncs with the new ipod and it definitely updates songs/playlists, but after that it gives me the error message about not being able to update.
    i ran the last updater, and it says my ipod is up to date.
    what's going wrong? i must have done something wrong.

    or not....i spoke too soon!
    it's doing it AGAIN. after it started updating after restoring all was well, it tried to add my whole library which won't fit.
    when it add's a "library selection" instead automatically, it fills up my ipod so that the photos won't update.
    then when i re-mount the ipod, it gives me the same old error message again about missing the file required for updating!?!?!?
    i wish my preference to "manually add songs" instead of syncing the library would save in Itunes when i restore my Ipod. it's making it impossible for me to get things working properly after restoring....

  • On my MacBook with Lion Safari does start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library did not help. Where can I find and remove all components (LastSession ...)?

    How can I reset Safari with all components? On my MacBook with Lion, Safari does not start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library does not help. Where can I find and remove all components as LastSession and TopSites?

    The only way to reinstall Safari on a Mac running v10.7 Lion is to restore OS X using OS X Recovery
    Instead of restoring OS X in order to reinstall Safari, try troubleshooting extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.
    If it's not an extensions issue, try troubleshooting third party plug-ins.
    Back to Safari > Preferences. This time select the Security tab. Deselect:  Allow plug-ins. Quit and relaunch Safari to test.
    If that made a difference, instructions for troubleshooting plugins here.
    If it's not an extension or plug-in issue, delete the cache.
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.

  • I have no trouble viewing apps in the iTunes Store on my iPad. However, every time I try to install a new app, I get an error message after a while - cannot connect to iTunes Store. This issues cropped up two days ago on my new iPad. Please help...

    I have no trouble viewing apps in the iTunes Store on my iPad. However, every time I try to install a new app, I get an error message after a while - cannot connect to iTunes Store. This issues cropped up two days ago on my new iPad. Please help...

    JUst experienced the exact  same problem after changing password.Getting same message. Hope someone has an answer for this.

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • How can i get back my data after i restored my iphone and accidentally created a new iphone ac.

    how can i get back my data after i restored my iphone and accidentally created a new iphone ac.
    it did a back up when i started my restored iphone and i cant retrieve my previous backup while i didnt back up on icloud....
    the new ac is actually the same apple id as the one i used. I lost all my contact, photos and data of whatsapp...
    what can i do...help!

    I don't know if this is a similar problem but I wrote 2 notes yesterday on my iphone. I opened my mail to print them and they appeared as notes but wouldn't load. Then I looked at them on my iphone and I could see the notes but they quickly updated to blank with a time of the last edit the same time I tried opening them on my computer.
    Yesterday I updated to 4.3.4  I don't know if somehow that affected them. Are they stored somewhere else. Can I get them back?

  • My iPad mini adapter shorted...I bought a new one but since it charges very slowly and when charged to 100% it falls to 95% immediately after being unplugged...what might be the issue????

    my iPad mini adapter shorted...I bought a new one but since it charges very slowly and when charged to 100% it falls to 95% immediately after being unplugged...what might be the issue????

    When it does that. Replug the charger and charge to 100%. Now does is stay charged when you unplug the charger.
    You may need to recalibrate your battery.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
     Cheers, Tom

Maybe you are looking for