Updating Window Size.  Please help

Hi. I have a problem that I am encountering and was wondering if anyone might know of how to solve it... I have a class called CenteredFrame that extends JFrame, and other classes extends CenteredFrame. I want to be able change the size of the windows to accomodate font changes and only have scrollpane when needed (this is when the window is at its maximum size). Because each class extending CenteredFrame may have its own layouts and sizes, I returned a panel for JContentPane and placed that inside of the scrollpane. One problem I am having upon testing one class extending CenteredFrame is that when apply button is pressed for font changes, refreshFrame is called but the window does not resize properly until the apply button is clicked a second time. Does anyone have an idea how to fix this? A second problem is that some of the classes extending CenteredFrame does not appear properly, buttons may be out of place even though it looked fine before scrollpane was implemented. All ideas would be helpful. Thanks.
Here is the code
public class CenteredFrame extends JFrame implements WindowListener {
private JPanel mainPanel = new JPanel();
private JScrollPane centeredFrameScrollPane;
* Constructor
public CenteredFrame() {
super();
getContentPane().setLayout(new BorderLayout());
centeredFrameScrollPane = new JScrollPane(mainPanel);
super.getContentPane().add(centeredFrameScrollPane);
//mainPanel.setLayout(new GridLayout());
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(this);
* Used as a local getContentPane method in order to allow for
* scollpane
public Container getContentPane() {
return mainPanel;
* This is used for resizing the windows if font or component sizes
* changes
public void refreshFrame() {
centeredFrameScrollPane.getViewport().setExtentSize
(centeredFrameScrollPane.getViewport().getViewSize());
pack();

I have not actualy tested it but how about invalidating and then packing the CenteredFrame's content pane before calling setExtentSize. If the content pane has not had its layout updated how does getViewSize know how big the content pane wants to be with the new fonts?
As you code stands the pack is probably updating the layout of the content pane and then the second time you press "Apply" the getViewSize returns the updated information and everything works.
Ian

Similar Messages

  • My iphoto wont open since i updated my mac, please help? it says i need to install an iphoto library upgrader which I have installed but still cant see my photos.

    my iphoto wont open since i updated my mac, please help? it says i need to install an iphoto library upgrader which I have installed but still cant see my photos.

    What version of iPhoto are you using? 9.6 is the current version.
    Do a backup.
    Quit the application.
    Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J.  When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder.  Select Library. Then go to Preferences/com.apple.iPhoto.plist. Move the .plist to your desktop.
    Restart, open the application and test. If it works okay, delete the plist from the desktop.
    If the application is the same, return the .plist to where you got it from, overwriting the newer one.
    Thanks to leonie for some information contained in this.

  • My ipod touch is stuck on the 4.2.1 software, its a 3rd gen as well i was just wondering why i can not get the lastest update can you please help me with this issue

    i have been having an issue with updating my ipod touch for some time now and i can not seem to get it to update to the lastest update. it is stuck on 4.2.1 software and i can not update it to 4.3 or any other ios software update. can you please help me to solve this issue.

    It sounds like you actually have a 2G iPod Touch which can only go as high as iOS 4.2.1.  If it's an 8 GB iPod Touch it's definitely a 2G iPod Touch as there was never such a thing as a 3G 8 GB iPod Touch. See this article to help verify what generation iPod Touch you have.
    Identifying iPod models
    B-rock

  • How do I delete movies from iTunes library? I have moved them to the iCloud and now only seem to have the option to hide the icon in iCloud.  I am sure I chose poorly at the 'keep file' window.  Please help. My Brain hurts- 18   movies need to go-.

    How do I delete movies from iTunes library? I have moved them to the iCloud and now only seem to have the option to hide the icon in iCloud.  I am sure I chose poorly at the 'keep file' window.  Please help. My Brain hurts… 18 plus movies need to go….  Thank you.

    Instead of removing the music from the cloud or the iTunes library why not shuffle your music using a Smart Playlist which excludes the holiday music, or tracks that are not checked. For example, use this very simple Smart Playlist:

  • My ipad mini is not syncing music onto in, my ipad has been replaced to see whether the issue is to do with the ipad but its still not working. i have a a windows PC please help thanks

    my ipad mini is not syncing music onto in, my ipad has been replaced to see whether the issue is to do with the ipad but its still not working.
    ive tried everything and ive been to the store which was when i was given a new ipad mini. i have a a windows PC please help thanks

    Are you attempting to sync music from your iTunes Music Library on your PC?
    What options do you have set on the Music Tab for your iPad in iTunes?
    What happens when you sync?
    Any error messages?

  • My ipod 3rd generation is not recognized by windows/itunes,please help

    My ipod 3rd generation is not recognized by windows/itunes,please help. Have tried restoring a number of times but did not work, any suggestions?thanks

    Start with this Apple support document.
    http://support.apple.com/kb/TS1369
    B-rock

  • Bluetooth shuttted down after I updated to Mavericks, please help me !  I am 70 Years old and worked very happy with my iMac (21,5" mid 2010, 3,2 GHz Intel Core 3) until I updated him from  SnowLeopard 10.6.8 to Mavericks 10.9.2. 2 Days all was OK. Next M

    Bluetooth shuttted down after I updated to Mavericks, please help me !
    I am 70 Years old and worked very happy with my iMac (21,5“ mid 2010, 3,2 GHz Intel Core 3)
    until I updated him from  SnowLeopard 10.6.8 to Mavericks 10.9.2.
    2 Days all was OK. Next Morning-Start he needs (until now) 3 minutes to show me a SCREEN only milky white. After that he starts like ever with all ICONS in about 1 minute. (together 4 min.)
    ..But I must notice, that I cannot make anything, because the „BLUETOOTH APPLE WIRELESS KEYBOARD  and the APPLE  MAGIC MOUSE“ doesn't work anything like before.
    I could nothing do, I must drop my APPLE only out.
    That I maked ever 10x and all was the same... (Maveriks also 4x new updated)
    I taked my Logitech-Bluetooth-Mouse from the WIN-Laptop, dropped it in USB from iMAC...and in one second I could work only with this MOUSE...I buyd the Logitech COMBO K520 and all was OK now with my lovely APPLE iMAC to work with him...But without APPLE KEYBOARD and MAGIC MOUSE...and with a 4 min. -START until now.
    I  asked the EXPERTS from APPLE-SUPPORT under Tel. 0800-6645451 in Germany, became a Number, maked many Things by starting new, but the mistake after all is the same like before.
    When I look into ...Apple/ Info/System/ Hardware/ Bluetooth   ..my APPLE says: NO INFOs FOUND (Es wurden keine Informationen gefunden.)
    Under Hardware/ Diagnose : Selbsttest beim Einschalten: zuletzt ausgeführt: 15.05. 14, Ergebnis: Bestanden (that means OK) !!
    I asked many Peaple, who sold APPLE-Computers in the STORS, but they all had no IDEA, how they can help.
    I think, it could be a DRIVER when Starting the BIOS, JAVA RUNTIME a.s.o...
    Is an Expert under YOU to help me by my Problem with this iMAC ?

    dietmarfromdeu,
    if you start up your iMac in Safe mode, do you still have Bluetooth problems with your Apple wireless keyboard and Magic Mouse?

  • HT4623 hi..i just bought an iphone 5 yesterday 32GB..and now when i am trying to update the software..it says the following: unable to check for update/an error occurred while cheking for a software update...please help me..is it a problem in my new iphon

    hi..i just bought an iphone 5 yesterday 32GB..and now when i am trying to update the software..it says the following: unable to check for update/an error occurred while cheking for a software update...please help me..is it a problem in my new iphone??or it's just an temporary error in the apple software center???

    Lyndsay237 wrote:
    This device does not have a sim card in it. Could this be the reason or am I missing something when I am trying to update.
    Yes. You can't update or restore any GSM iPhone without a valid sim card installed in the phone. The sim card need not be activated, but it must be valid & present. If you want to update, you need to get a sim card.

  • I updated the spelling of a song in my itunes but its not reflecting when i check my ipod. this never happened before when after i updated to IOS5. please help.

    i updated the spelling of a song in my itunes but its not reflecting when i check my ipod. this never happened before when after i updated to IOS5. please help.

    Try unsyncing the sone and then resyncing. That works sometimes. Sometimes restoring from backup works. Other times nothing seems to work.. Yuo are not alone since iOS5 and iTunes 10.5/6.

  • I shot a video clip(800MB) using my iPhone4s but could not copy to my PC (windows XP),please help me

    I shot a video clip(800MB) using my iPhone4s but could not copy to my PC (windows XP),please help me

    Limitation of XP, videos over 500MB's can't be imported using Camera/Scanner wizard. Try transfering these Videos directly from your phone by selecting them in My Computer and dragging or copying the movie files to your computer's hard drive.

  • I am still trying to update my ipod touch 4 to the iOS 6 version. It is on the 4.3.5 (8L1) version. When I go to settings-General-it just says About and nothing about an update. I have no idea how to update it! Please help!

    I am still trying to update my Ipod touch 4 to the iOS 6 version. It is on the 4.3.5 (8L1) version. When I go to settings-General-it just says About and nothing about an update. I have no idea how to update it! Please help!

    You can only update via the ipod with ios 5 or later.
    You need to update via itunes on your computer as always.

  • Can't download latest iTunes on Windows 7, please help?

    Hi,
    I'm having trouble downloading the lastest version of iTunes from the apple website.
    I clicked download iTunes etc and then got the itunessetup thingy, so I tried installing it but within seconds the wizard does to the end page and says:
    'ITunes installer completed.
    The installer encountered errors before itunes could be configured. Errors occured during installation. Your system has not been modified.
    Please run the installer again, or click finish to exit.'
    I have tried installing it several times and keep getting the same issue. I also uninstalled everything I have from Apple on my laptop and tried installing iTunes again then with no luck.
    It's really frustrating me now and i have no idea what to do. I've tried searching this issue but other people have posted about different problems to this one so I dont know how to fix it. Help please?
    Thanks

    new to Windows 8, please help me.
    Coming from Windows 7?  It is quite analogous, especially if you were a keyboard user.  Ctrl-Esc (or press and release Win) shows you the equivalent of the Start Menu, which is now called the Start Screen.  In W7 once you brought up the
    Start Menu you may have been aware that you could either click on pinned items, click on pinned Taskbar buttons, click on Desktop shortcuts, OR... do some typing to bring something up from your installed applications.  Well, in W8 we could do the first
    and the last completely the same and now in W8.1.1 we can do all of those things.  There are also new options which can keep you mostly oblivious of the Start Screen if you would prefer to do that.
    But to answer your specific example, after you see the Start Screen (or All apps view of it) just start typing P O
    FYI
    Robert Aldwinckle

  • Boot Camp won't let me remove my windows partition, please help

    I am trying to remove my windows partition and boot camp won't let me. It gives me a message +" The startup disk must be formatted as a single Mac OS Extended (Journaled) volume or already partitioned by Boot Camp Assistant for installing Windows."+ Please help!!!!!

    Use the Disk Utility to delete it and resize the partition immediately above of it so it takes up the released space.
    (51550)

  • I have been trying to put some of my music and artwork, on youtube. Youtube says you need an encoder to upload music. But the problem is the only encoders available are for windows. Please help, thank you

    I have been trying to put some of my music and artwork, on youtube. Youtube says you need an encoder to upload music. But the problem is the only encoders available are for windows. Please help, thank you

    The formats YouTube supports can be found here:
    http://www.google.com/support/youtube/bin/answer.py?answer=55744
    Since YouTube supports AAC, the file format iTunes uses by default, it's probable you don't need any sort of converter.
    If you continue to have problems with uploading to YouTube, I'd suggest you ask for assistance in their forums:
    http://www.google.com/support/forum/p/youtube?hl=en
    Regards.

  • HT204074 My PC is not getting authorized & I am not able to sync my I pad with my PC any more nor Im able to install any app. I recently reinstalled my windows. Please help. I tried authorizing with my ID but it still shows the message computer is no long

    My PC is not getting authorized & I am not able to sync my I pad with my PC any more nor Im able to install any app. I recently reinstalled my windows. Please help. I tried authorizing with my ID but it still shows the message computer is no longer authorized.

    It may think it's a new computer.
    Sync Your iOS Device with a New Computer Without Losing Data
    http://www.howtogeek.com/104298/sync-your-ios-device-with-a-new-computer-without -losing-data/
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive
    https://discussions.apple.com/docs/DOC-3141
     Cheers, Tom

  • Can't sync Palm Centro and Outlook 2007/Windows 7 - please help!

    Hello,
    I've never posted on a forum, but I'm at my wits end...!  I've been trying to get my Palm Centro to sync Contacts/Calendar/Memos to Outlook 2007 on my new laptop for a week now with no success.  It used to sync just fine to my old computer with Windows XP and Outlook 2003.  Then that computer crashed (my Outlook files were backed up on an external harddrive).  I received my new computer with Windows 7 XP (32-bit) and Outlook 2007.  I've downloaded the Palm Desktop 6.2, Windows 2007 Conduit, and Software Update 1.03 (Windows installer) for Centro for Verizon. 
    When I sync my phone to my new Outlook, it completes all 12 steps, but does not load Contacts/Calendar/Memos to Outlook.  This is a list of the error messages:
       HotSync session started on 04/14/10 12:11:25, and completed in 100.0 seconds
     Outlook Calendar synchronization completed with messages
     Duration: 5.4 seconds
     Outlook Calendar
     Please set the option "Enable Synchronization when Outlook is offline" in UI inorder to synchronize in Offline mode
     OLERR:0C-000F (0x0)
     OLERR:0D-0003
     OLERR:0D-0001
     - Not Synchronized
     Outlook Contacts synchronized successfully
     Duration: 0.0 seconds
     Outlook Contacts
     OLERR:0C-000F (0x0)
     OLERR:0D-0003
     OLERR:0D-0001
     - Not Synchronized
     Outlook Tasks synchronized successfully
     Duration: 0.0 seconds
     Outlook Tasks
     OLERR:0C-000F (0x0)
     OLERR:0D-0003
     OLERR:0D-0001
     - Not Synchronized
     Outlook Notes synchronized successfully
     Duration: 0.0 seconds
     Outlook Notes
     OLERR:0C-000F (0x0)
     OLERR:0D-0003
     OLERR:0D-0001
     - Not Synchronized
     Media synchronized successfully Duration: 3.8 seconds
     Backed up some files successfully to Backup Folder 
     Duration: 90.0 seconds
     Backed up 9 file(s) successfully
     AddressingLibRecent-HsCh
     AddressingLibRecent-HsCi
     Messages Database
     PhoneCallDB
     Cookie Data
     AddressCompaniesDB
     psysLaunchDB
     Saved Preferences
     AddressTitlesDB
     Failed to backup 1 file(s) PmTraceDatabase Protocol Error: Handheld file could not be opened. (4004) SYNCERR_FILE_NOT_OPEN
    Can someone please help me transfer Contacts/Calendar/Memos from my Palm Centro to my computer's Outlook 2007?
    I've ready about 3rd party software in posts (Pocket Mirror), but I don't know if it applies here because the Contact/Calendar/Memo information is in my Centro - not in Outlook.  I need to get it from my Centro to Outlook 2007. 
    Any help is greatly appreciated!  Thank you!

    hat wrote:
    I have a Pre Plus and am using CompanionLink software.  If the Centro is like the Plus (which I believe it is) it will not sync with Outlook.  Here is a link to Companion Link:
    http://www.companionlink.com/index.html
    I have been using this and it works great.  On their site you can choose the phone and the particular program you need to sync with and choose which you way you want to sync.
    Hope this helps
    Sorry hat, the Centro has absolutely nothing in common with a webOS device!  It runs PalmOS.  Nice of you to reply with your suggestion though! 
    @SyncHelpPlease:  OLERR errors are covered in this Palm KB article:
    http://kb.palm.com/wps/portal/kb/common/article/31167_en.html
    Something I noticed in your post - you installed Palm 6.2.2 AND the 2007 conduit.  Palm Desktop 6.2.2. has the 2007 conduits built into it already, and the patch is not needed.  Whether this is the cause of your problems, I'm not sure, but I've fielded several posts of the same issue where the user did the same thing you did!
    I'd suggest doing a clean uninstall, and reinstall of Palm Desktop 6.2.2 only. 
    I admit, I do not use Outlook, nor Win7, so I'm giving you my best guess at a way to solve your problem.  Hopefully, this may lead to a solution! 
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

Maybe you are looking for