Image in panel not available right away?

I'm sure this simple beginner's question has been answered scores of times but I can't find a working explaination.
I have a class, ImagePanel, that extends jPanel.
public class ImagePanel extends JPanel implements Serializable {
    Image image = null;
    public ImagePanel() {
    public ImagePanel(Image image) {
        this.image = image;
    public void setImage(Image image){
        this.image = image;
    public Image getImage(Image image){
        return image;
    public void paintComponent(Graphics g) {
        super.paintComponent(g); //paint background
        if (image != null) { //there is a picture: draw it
            int height = this.getSize().height;
            int width = this.getSize().width;
            g.drawImage(image,0,0, width, height, this);
            //g.drawImage(image, 0, 0, this); //original image size
         }  //end if
    } //end paint
} //end classIn my main form, I set an image from a file:
   private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                     
        JFileChooser jFileChooser1 = new JFileChooser();
        jFileChooser1.setCurrentDirectory(new File("."));
        int result = jFileChooser1.showOpenDialog(mainPanel);
        if (result == jFileChooser1.APPROVE_OPTION) {
            String filename = jFileChooser1.getSelectedFile().getAbsolutePath();
            Image image = Toolkit.getDefaultToolkit().getImage(filename);
            imagePanel1.setImage(image);
        }When I first run the program and load an image, the image does not appear. If I deactivate the form then reactivate it, I can see my image.
Thereafter, whenever I load a new image, it appears immediately.
How do I make my loaded image render when I load an image immediately after starting the application?

Toolkit loads an image in the background, so it may be some time before the image is completely loaded. ImageIO#read(...) blocks until the image is fully loaded. And yes, it's been answered scores of times.
Also,even if the image has actually loaded fully, your setImage(...) method doesn't call repaint() so the newly set image would only be painted at the next repaint, which would occur
If I deactivate the form then reactivate itdb

Similar Messages

  • Facetime: user not available right away after dial

    When I am trying to do a Facetime Call (Audio and Facetime video), it gives right away a message of "User not available for Facetime". This number used to work no problem before. I tried to do a test with another Iphone to find the reason why this happened. So I found out that it couldn't be a number block nor a Facetime being turned off. Anyone know the reason why it jumps directly to the message of "User not available"?
    It seems like an auto-decline incoming calls, but Iphone does not have such option.
    Thanks

    Theres nothing wrong with your phone, it could mean any if the following:
    The person(s) you are callig have blocked you
    The person(s) have a dead phone
    The person(s) aren't accepting calls
    Hope I helped!

  • My iPad 3 Will not update ils apps.. They are there but I can't open them... I have Internet .. It just says not available right now.. It's been 3 days????

    My iPad 3 Will not update ils apps.. They are there but I can't open them... I have Internet .. It just says not available right now.. It's been 3 days????

    Quick update, the duplicate of the comic-con episode downloaded succesfully, and so has the first episode of Supernatural season 8. Blue dots appear to their left in the library.
    All the Vampire Diaries episodes (except the bonus comic-con double) have vanished, but I paid for them !
    They're not anywhere on my harddrive either.
    Which is new by the way, this is a new MacbookPro, literally set it up today.
    So it would seem this is a case of purchased and pseudo-downloaded episodes that ended up beinge gobbled up by some iTunes black hole, leaving me with no money, and no episodes.
    Need help, confirmed.

  • Photoshop 11 continues to not load right away and continously freezes. How can I fix this problem as I've been informed that Adobe will not help me.

    Photoshop 11 continues to not load right away and continously freezes. How can I fix this problem as I've been informed that Adobe will not help me.

    This has been going on for months for me. Time to drop Firefox & go back to IE.

  • Sound Blaster X-FI Pci Express Front Panel Not working right Win7

    ASound Blaster X-FI Pci Express Front Panel Not working right Win7
    Please read carefully
    Part number Part SB040
    Hello,
    I have a fresh install of Win7x64 OEM. First, I want to say that I have "AUTOMATICALLY MUTE SPEAKERS" UNCHECKED under the Headphone detection tab. I have tried "Automatically Enable Headphone Settings" checked or unchecked. No difference.
    As soon as I plug in headphones to the front panel connector , the speakers in the mixer say "disconnected" (see below) and the SPDIF becomes the default output. There is no way for me to change this. And there isn't any sound coming from the headphones when plugged into the front panel. (the mic front panel works fine)
    I am using the nati've Win7 drivers for the card. Apparently the Win 7 drivers on your site are older than the nati've ones.
    This worked fine in Windows XP 32. Any ideas.

    Ok guys this is how I fixed the problem on my X-Fi PCI-Express. Open the Creative SB X-Fi Volume panel. Mine is set in game mode and I have 5 vertical sliders for Line-In /Mic, MIDI Synth, Digital-In, and the last one will say one of three things either Digital-In, Microphone, or Mirophone FP. At the top of the?slider there is a tab which brings up a drop down menu. Mine was default set to Digital-In, I switched it to Mirophone FP (tried Microphone first and it worked but the FP sounds better for me) and cranked it all the way up and my problem was solved. Very frustrating one though as there is no documentation that led me to the fix it was just playing around with it till I could figure it out.
    I hope this at least helps some of you out.

  • Since image extractor is not available in elements 12, what can I used instead?

    Since image extractor is not available in elements 12, what can I used instead?

    You can also use refine edge once you've selected the object, which does a fine job, but is very fiddly to learn to use.
    https://www.youtube.com/watch?v=xrl3Qwg6zSc&feature=c4-overview-vl&list=PL310C228653956E4B

  • Firefox does not open right away

    A few hours ago, firefox would not open right away for me . i was attempting to go on the internet and mozilla firefox 3.6.12 would not open right away for me. i had to restart my computer. also, mozilla did crash before that when i attempted to go into yahoo to check out my e-mail.

    Try to boot the computer in Windows Safe mode with network support (press F8 on the boot screen) as a test to see if that helps.
    A possible cause is security software (firewall,anti-virus) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls

  • The Kuler panel not available in Adobe Photoshop CS6 french language pack ????

    Hello !
    Why the Kuler panel is not available in Adobe Photoshop & Illustrator CS6 french language ???? it's ok when I make an Int. US language install ! can I find the kuler.atn somewhere?
    Only the Mini Bridge appears in the extention panel....
    thanx for your help !

    and I suppose it's the same in the Canadian law too . So, if I understand you, I buy an incomplete software without any information from Adobe about that !!!!! and you don't alow me to use a complet french version of the software I paid and use on the US country because of a French law that nobody knows neither follow except ADOBE?????  can you explain me more because I really don't understand your "no answer" to explain an other bug in your software... Why do you sell it as an incomplet solution at the same price in that case? Just have to inform every users about that and we will baught the US (or other language) versions in place of the french one...
    Is there finaly a temporary solution to find & install the kuler extention from the US version to the french version in Photoshop & Illustrator (by myself, of course and without the agreement of ADOBE )

  • Indesign CS 4 assignment panel not available on mac

    Using indesign CS4. Assignment panel under window menu is not available. Any help will be appraciated

    Hi Bob
    Thanx for the follow-up. Sorry for the confusion. I was trying to work on your suggestion to move the discssion to Indesign but couldnt find a mechanism to move discussion, so I ended up creating another one under InDesign. Now I need to cancel/delete/close the one in creative Suit???
    As for your reply, I did go down to the end of the window menu, but could not see any option as "display all menu item choice"
    Is they any setting in perferences  etc.....
    Cheers

  • Flash CC - Exchange Panel not available

    I`m posting this in the Flash and not the Exchange forums, because the rest of my CC apps, don´t have this problem, only Flash has:
    1.Installed AdobeExchange 1.2.0 with the newest Extension Manager (7.0.0.347)  on Win7x64
    2.Exchange doesn`t show up under Extensions in Flash (but does so in illustrator, Photoshop, Dreamweaver etc), even after reboot.
    Anyone has a workaround for this problem?

    Exchange Panel is currently not available for Flash CC as mentioned in link https://www.adobeexchange.com/ under the "View Application" dropdown.
    You will need to install the extensions via Extension manager until the panel gets re-enabled in a later update to flash pro.
    -Sujai

  • Songs are not displayed right away

    upon inserting CD, song names/cd info does not show unless I click on advanced/get song names. My computer used to find all this info right away, but changed with the new itunes update. Any ideas?

    I have the ZenV Plus, 2 gb and it lists the songs by Artist, by Album, by Genre and then it has a complete alphabetical list of the songs by title (All tracks). Don't you have this option uner your "Music Library"

  • Finder Locks up if not used right away

    Hi Everyone!
      On my 2.4GHz Intel Core 2 Duo 24" iMac running Mountain Lion, latest updates, I'm finding the following problems that I can't quite figure out and was hoping someone might have an idea:
    Start up very slow - at least 3-4 min.
    It takes a VERY long time to populate the finder windows.   If I open a finder window it's empty for about 30 sec. before it starts populating and even then it takes quite a bit of time for the icons to change from generic to their proper symbols
    Once it's up and running, if I start using it right away, it's fine.  But if I walk away and don't use the computer for a few minutes, the finder locks up.  The mouse pointer will move, and if a program is open windows can be closed, but nothing can be initiated.  If my browser is open (Chrome), eventually I get this page is unresponsive alert.  No functions, no new windows in any program.  And eventually the beach ball comes on.  I've tried to wait it out for as much as 30 min. without success.  Opening Force Quit and it's showing the Finder as unresponsive, but force quitting does nothing.  I have to manually shut down by using the power button.
    When I check the console for error messages, there are none.  Very few messages at all.
    I can upload more info when I get home tonight, but in the meantime, does this ring any bells for anyone?
    THANKS!

    Try setting up another admin user account to see if the same problem continues. If Back-to-My Mac is selected in System Preferences, the Guest account will not work. The intent is to see if it is specific to one account or a system wide problem. This account can be deleted later.
    Isolating an issue by using another user account
    If the problem is still there, try booting into the Safe Mode using your normal account.  Disconnect all peripherals except those needed for the test. Shut down the computer and then power it back up. Immediately after hearing the startup chime, hold down the shift key and continue to hold it until the gray Apple icon and a progress bar appear. The boot up is significantly slower than normal. This will reset some caches, forces a directory check, and disables all startup and login items, among other things. When you reboot normally, the initial reboot may be slower than normal. If the system operates normally, there may be 3rd party applications which are causing a problem. Try deleting/disabling the third party applications after a restart by using the application un-installer. For each disable/delete, you will need to restart if you don't do them all at once.
    Safe Mode
    Safe Mode - About

  • What does "Sorry, delivery dates not available right now." mean?

    I am trying to order a TV and I keep getting this error message.  Does this mean that the TV is completely out of stock in my area or does this mean that the TV delivery team is completely booked for the foreseable future?  I tried another zip code in a different part of the US for the same TV and I don't get this error message.  Thanks...

    Hello SRZ, 
    This Samsung TV looks amazing and I'm glad to hear you were able to snag it! To my knowledge this message may be received if we do not have any delivery appointments available or if stock is not available. 
    I apologize for any concern this message may have caused you, and for any disappointment you may have encountered when you received a distant delivery date. If you should have any questions, please let me know! 
    Regards,
    Tasha|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Password - when entering letters, not "dots" right away...

    Hi all
    I have an original iPhone recently upgraded to the 2.0 software. When I enter in a password now into a password field, instead of getting the "*" right away, I first see a letter and then a moment later it turns into the dot. I don't like the idea of having a password be visible on screen. Is there a way to fix this in the new settings?

    I can understand why it would be a problem and I'm sorry you don't like it. It would be nice to have the option to turn it off, but I LOVE it!
    I can tell right away now if I screw up a password. Especially when entering my WEP key at work! Every so often they shut down the WiFi and when they restart, you have to re-enter the key. It's looooong! It's nice to see the characters for a second, so I don't have to try to enter it a million times!

  • Image Content Item not available

    I am trying to add a new image content in Site Studio.
    I Click on the "New" icon -> "Copy" -> "From Local", choose the image (jpeg) and Fill Out the "Check-In" form. I see that the new content Item is added in the list of Images.
    1) I refresh the list. The newly added content is gone.
    2) I open my page inContributor mode. I go to image elementl and try to browse for this newly added image. I am not able to find it.
    3) I try searching for the image in UCM Search form - with the Content ID. I am still not able to find the content.
    So, I thought the content was not created in the first place and tried to upload my image again, with the same Content Id. It says my Content Id is not unique - only that I am not able to find the content with that Content Id.
    Can someone please help me debug this?

    So, another developer had created a Workflow (for testing some stuff) that will pickup all Images for Review. It was holding up all the images that I was uploading.
    Now, I got the workflow disabled. The Contents have gotten released, and those content are now available from the image element.
    Thanks.
    Edited by: 926653 on Nov 5, 2012 12:33 PM

Maybe you are looking for

  • Jar file in web-inf\lib is not being loaded - weblogic 7.0

    I am callling a webservice from a jsp. everything works fine if I keep the interface classes under web-inf\classes....but If I put the interface classes in a jar file and put it under web-inf\lib, then weblogic does not seem to find that.... I am get

  • File Open Issues - document library pdf file to open in new browser window

    Hi I have a requirement to open the document library containing pdf file to open in new browser window. So far I have tried following steps but could not get it to work. 1. Changing Document library advance setting to open the document in browser (ha

  • Errors in mod_jserv.log

    Hi, We are getting below errors in Jserv logs.No errors were found in Apache logs [01/03/2009 14:45:11:765] (ERROR) an error returned handling request via protocol "balance" [01/03/2009 16:16:42:514] (ERROR) ajp12: Servlet Error: java.lang.NullPointe

  • Help with sample schema

    Hello. I am reading a self teaching guide called databases demystified by andy oppel. In the book it says that a sample hr schema is used to demonstrate sql. It then leads the reader to download a free trial version of oracle personal edition from ot

  • String to words

    Hello, To split this string "SMITH","ALLEN","WARD","JONES" into a list of names : SMITH ALLEN WARD JONES I use this query. select regexp_substr('"SMITH","ALLEN","WARD","JONES"','[^","]+', 1, level) from dual connect by regexp_substr('"SMITH","ALLEN",