Image only shows after screen is reloaded (hidden and showed again)

Hello everyone,
I have a class that calls a drawImage. The thing is that it was supposed to be shown when the JFrame is shown, but it isn't. It is only shown after I hide it and show it again (like after I minimize it and minimize it back.
Can anyone help me here? I need it loading without nothing being done by the user.
Here goes my class:
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.applet.*;
import sun.audio.*;
import java.io.*;
public class Shapes extends JFrame
    public Image imagem;
    public Shapes(Integer resultado, Image imagem)
        super("Grafico dos Valores");
        setBounds( 0, 0, 900, 570 );
        getContentPane().setLayout(null);
        this.imagem = imagem;
        setVisible(true);
        getGraphics().drawImage(imagem, 20, 20, null);   
    public void paint(Graphics g)
        super.paint(g);
        Graphics2D g2d = ( Graphics2D ) g;
        g2d.drawImage(imagem, 20, 20, null);   
    }

1) Swing related questions should be posted in the Swing forum
2) Don't override the paint(...) method of JFrame
3) Don't use getGraphics to draw your image
4) If you need to do custom painting then override paintComponent(..) of JPanel or JComponent
5) Read the tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html]Custom Painting

Similar Messages

  • My ipad 2 suddenly show red screen during start up and on ordinary screen show red colure fill the screen , I think it is hardware problem mostly screen. This problem didn't happen after fall or only accident ,what shall I do .

    My ipad 2 suddenly show red screen during start up and on ordinary screen show red colure fill the screen , I think it is hardware problem mostly screen. This problem didn't happen after fall or only accident ,what shall I do ?

    You could try a reset and see if that fixes it : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.
    If it doesn't then you could try restoring to your last backup and/or resetting back to factory defaults. But if it's a hardware issue then you will need to contact Apple.

  • I click s/w update in ipad after few mints its screen turns to black and showing itunes logo..plz suggest wht to do

    i click s/w update in ipad after few mints its screen turns to black and showing itunes logo..plz suggest wht to do

    Do exactly what the screen is telling you to do. Connect the iPad to your computer and launch iTunes. You either have to update the software that way, or you have to restore the iPad because something went wrong with the update.

  • My ipad is taking restart automatically and screen is fully balck and showing only apple logo.please give me solution for that

    my ipad is taking restart automatically and screen is fully balck and showing only apple logo.please give me solution for that

    Have you tried a reset first? If it works, you won't have to go through the restore process.
    Hold down the sleep (upper right hand top) and the home button at the same time. A slider will appear. Ignore it and keep holding down the buttons. The Apple logo shoud appear. Then your ipad might work again. It takes a good 15 seconds. You will not lose anything on your ipad.
    If you try it a couple of times and it doesn't work, you might have to go through the restore process as has been suggested above. But follow the steps so you don't lose your data.
    Hope this helps.

  • Haw do i put evry thin back on my ipod as i accadently wiped evry thin off and now it just shows a screen with the lead and itune bubble

    haw do i get my ipod 2 work after i accedently wiped evry thin off and now it just shows a screen with the lead and a itunes bubble

    dennisfromabertillery wrote:
    haw do i get my ipod 2 work after i accedently wiped evry thin off and now it just shows a screen with the lead and a itunes bubble
    Connect to your computer, fire up iTunes and do a Restore:  From iTunes, select the iPad and then select the Summary tab.  Follow directions for Restore.

  • TS1559 i have problem in wifi it's hidden and show a message that : no wifi-fi so how can i fix it ?

    i have problem in wifi it's hidden and show a message that : no wifi-fi

    You said " I tried updating via iTunes but that also produced an error message.".
    What did that error message say?

  • Help please! My macbook air (2015) startup showed a folder with question mark so i tried "Command   R" for internet recovery but after few minutes it stopped and showed error.. Please hepl me!

    Help please! My macbook air (2015) startup showed a folder with question mark so i tried "Command   R" for internet recovery but after few minutes it stopped and showed error.. Please hepl me!

    Startup – Question Mark
    Startup Issues - Resolve
    Startup Issues - Resolve (2)
    Startup Issues - Resolve (3)

  • MacBook Pro continues to reboot then shows main screen with flickering green and white lines then restarts again what the heck is wrong with it?!

    MacBook Pro continues to reboot then shows main screen with flickering green and white lines then restarts again what the heck is wrong with it?!

    Sorry we can't assist with that, you'll have to take it to Apple.
    If it's not worth fixing then you may be interested in this User tip
    My computer is not working, is my personal data lost?

  • Can some body give me an advice, my cursor can not be controlled after I shut it down, and open again. But this problem goes away after I closed and opened the lid

    Can some body give me an advice, my cursor can not be controlled (using pad) after I shut it down, and open again. But this problem goes away after I close and open the lid.

    Boot from your OS installer disk and run Repair Disk from Disk Utility.

  • I bought iphone 5s 2 days ago and suddenly it turn off and start again till the white screen with apple logo and start again

    i bought iphone 5s 2 days ago and suddenly it turn off and start again till the white screen with apple logo and start again
    please answer me as soon as possible

    Hello Ahmedabokamar,
    Thanks for the question! I'd recommend taking a look at the following article for troubleshooting steps that can help get your iPhone working again.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    Cheers,
    Allen

  • I have a 25" 2.8 GHz Intel core 2 Duo working on OS X 10.8.4, within past 2 days we've had the black screen and the white screen, we are up and kicking again but I can leave the computer playing music from iTunes, but within 10 minutes the screen is back.

    I have a 25" 2.8 GHz Intel core 2 Duo working on OS X 10.8.4, within past 2 days we've had the black screen and the white screen, we are up and kicking again but I can leave the computer playing music from iTunes, but within 10 minutes the screen is back, yet the music is still playing in the background. I can't get rid of the black screen unless I force quit the computer, then it starts ok. Then the process starts all over again.

    I have a 25" 2.8 GHz Intel core 2 Duo working on OS X 10.8.4, within past 2 days we've had the black screen and the white screen, we are up and kicking again but I can leave the computer playing music from iTunes, but within 10 minutes the screen is back, yet the music is still playing in the background. I can't get rid of the black screen unless I force quit the computer, then it starts ok. Then the process starts all over again.

  • Why when you log on by icloud on my iPhone show a message saying password error and try again Try again

    Why when you log on by icloud on my iPhone show a message saying password error and try again Try again????????

    Hey sergioo9,
    Thanks for the question. Based on what you stated, it seems like you are having trouble signing into Messages on OSX. I would recommend that you read this article, it may be able to help you resolve or isolate the issue.
    FaceTime, Game Center, Messages: Troubleshooting sign in issues - Apple Support
    Thanks for using Apple Support Communities.
    Cheers,
    Mario

  • Soundtrack Pro doesn't work. When I open it, i can only hear a heartbeat ticking sound over and over again.

    Soundtrack Pro doesn't work. When I open it, i can only hear a heartbeat ticking sound over and over again, then I get the spinning beach ball when I try playing a sound efx.

    Update: I tried reinstalling firefox, same thing happened again. When i stopped the process "plugin-container for firefox", i could use parts of firefox (didn't get an error sound) for a while, until the process "plugin-container" startet again.
    so what am i to do? switch to chrome?

  • Near Dead Ipod - Only shows black screen with apple logo and sick face ipod

    I would be very grateful for any help.
    I bought my 60GB ipod in the summer of 2005, whatever generation that makes it. Until recently it's been a little glitchy - sometimes the screen would appear to be functioning normally, but songs would not play. For example track 1 would look like it was about to play, then skip to track 2, then 3, and so forth. I had to force restart it regularly.
    Today I connected my ipod to my macbook and itunes appeared to start (bounced in the dashboard) then failed to launch. The ipod screen looked as though it was connected (flashing red sign) but did not mount on screen. I tried to force quit itunes, but that didn't work and the computer froze. I did a force restart of the computer with the ipod plugged in, and it took very long to restart. The whole time, the ipod screen continued to flash the red sign. I unplugged the ipod and force restarted it.
    Now, when I press menu, the black screen comes up with the apple logo, then periodically switches to a screen with an ipod with a sick face and "www.apple.com/support/ipod listed under it. I can hear a clicking sound when I hold it up to my ear.
    I've got 40 gigs of music on it and I'd very much like to get that off since much of it is not backed up. Am I screwed?
    C7

    Likely a hard drive failure
    If a sad iPod icon or an exclamation point and folder icon appears on your iPod’s screen, or with sounds of clicking or HD whirring, it is usually the sign of a hard drive problem and you have the power to do something about it now. Your silver bullet of resolving your iPod issue – is to restore your iPod to factory settings.
    http://docs.info.apple.com/article.html?artnum=60983
    If you're having trouble, try these steps at different levels one at a time until the issue is resolved. These steps will often whip your iPod back into shape.
    Make sure you do all the following “TRYs”
    A. Try to wait 30 minutes while iPod is charging.
    B. Try another FireWire or USB through Dock Connector cable.
    C. Try another FireWire or USB port on your computer .
    D. Try to disconnect all devices from your computer's FireWire and USB ports.
    E. Try to download and install the latest version of iPod software and iTunes
    http://www.apple.com/itunes/download/
    For old and other versions of iPod updater for window you can get here
    http://www.ipodwizard.net/showthread.php?t=7369
    F. Try these five steps (known as the five Rs) and it would conquer most iPod issues.
    http://www.apple.com/support/ipod/five_rs/
    G. Try to put the iPod into Disk Mode if it fails to appear on the desktop
    http://docs.info.apple.com/article.html?artnum=93651
    If none of these steps address the issue, you may need to go to Intermediate level listed below in logical order. Check from the top of the lists to see if that is what keeping iPod from appearing on your computer in order for doing the Restore.
    Intermediate Level
    A. Try to connect your iPod with another computer with the iPod updater pre-installed.
    B. Still can’t see your iPod, put it in Disk Mode and connect with a computer, instead of doing a Restore on iPod Updater. Go and format the iPod instead.
    For Mac computer
    1. Open the disk utility, hope your iPod appears there (left hand side), highlight it
    2. Go to Tab “Partition”, click either “Delete” or “Partition”, if fails, skip this step and go to 3
    3. Go to Tab “Erase” , choose Volume Format as “MAC OS Extended (Journaled), and click Erase, again if fails, skip it and go to 4
    4. Same as step 3, but open the “Security Options....” and choose “Zero Out Data” before click Erase. It will take 1 to 2 hours to complete.
    5. Eject your iPod and do a Reset
    6. Open the iTunes and click “Restore”
    For Window computer
    Go to folder “My Computer”
    Hope you can see your iPod there and right click on the iPod
    Choose “Format”. Ensure the settings are at “Default” and that “Quick Format” is not checked
    Now select “Format”
    Eject your iPod and do a Reset
    Open the iTunes 7 and click “Restore”
    In case you do not manage to do a “Format” on a window computer, try to use some 3rd party disk utility software, e.g.“HP USB Disk Storage Format Tool”.
    http://discussions.apple.com/thread.jspa?threadID=501330&tstart=0
    C. Windows users having trouble with their iPods should locate a Mac user. In many cases when an iPod won't show up on a PC that it will show up on the Mac. Then it can be restored. When the PC user returns to his computer the iPod will be recognized by the PC, reformatted for the PC, and usable again. By the way, it works in reverse too. A Mac user often can get his iPod back by connecting it to a PC and restoring it.
    Tips
    a. It does not matter whether the format is completed or not, the key is to erase (or partly) the corrupted firmware files on the Hard Drive of the iPod. After that, when the iPod re-connected with a computer, it will be recognized as an fresh external hard drive, it will show up on the iTunes.
    b. It is not a difficult issue for a Mac user to find a window base computer, for a PC user, if they can’t find any Mac user, they can go to a nearest Apple Shop for a favor.
    c. You may need to switch around the PC and Mac, try to do several attempts between “Format” and “Restore”
    http://discussions.apple.com/thread.jspa?messageID=2364921&#2364921
    Advance Level
    A. Diagnostic mode solution
    If you have tried trouble shooting your iPod to no avail after all the steps above, chances are your iPod has a hardware problem. The iPod's built-in Diagnostic Mode is a quick and easy way to determine if you have a "bad" iPod.
    You need to restart your iPod before putting it into Diagnostic Mode. Check that your hold switch is off by sliding the switch away from the headphone jack. Toggle it on and off to be safe.
    Press and hold the following combination of buttons simultaneously for approximately 10 seconds to reset the iPod.
    iPod 1G to 3G: "Menu" and "Play/Pause"
    iPod 4G+ (includes Photo, Nano, Video, and Mini): "Menu" and "Select"
    The Apple logo will appear and you should feel the hard drive spinning up. Press and hold the following sequence of buttons:
    iPod 1G to 3G: "REW", "FFW" and "Select"
    iPod 4G+ (includes Photo, Nano, Video, and Mini): "Back" and "Select"
    You will hear an audible chirp sound (3G models and higher) and the Apple logo should appear backwards. You are now in Diagnostic Mode. Navigate the list of tests using "REW" and "FFW". The scroll wheel will not function while in diagnostic mode. For further details on Diagnostic mode can be found at http://www.methodshop.com/mp3/ipodsupport/diagnosticmode/
    Try to do the 5in1, HDD R/W and HDD scan tests. Some successful cases have been reported after the running the few tests under the Diagnostic mode. In case it does not work in your case, and the scan tests reports show some errors then it proves your iPod has a hardware problem and it needs a repairing service.
    B. Format your iPod with a start disk
    I have not tried this solution myself, I heard that there were few successful cases that the users managed to get their iPod (you must put your iPod in disk mode before connecting with a computer) mounted by the computer, which was booted by a system startup disk. For Mac, you can use the Disk Utility (on the Tiger OS system disk), for PC user, you can use the window OS system disk. Try to find a way to reformat your iPod, again it does not matter which format (FAT32, NTFS or HFS+) you choose, the key is to erase the corrupted system files on the iPod. Then eject your iPod and do a Reset to switch out from Disk Mode. Reboot your computer at the normal way, connect your iPod back with it, open the iPod updater, and hopefully your iPod will appear there for the Restore.
    If none of these steps address the issue, your iPod may need to be repaired.
    Consider setting up a mail-in repair for your iPod http://depot.info.apple.com/ipod/
    Or visit your local Apple Retail Store http://www.apple.com/retail/
    In case your iPod is no longer covered by the warranty and you want to find a second repairing company, you can try iPodResQ or ifixit at your own risk
    http://www.ipodresq.com/index.php
    http://www.ifixit.com/
    Just in case that you are at the following situation
    Your iPod warranty is expired
    You don’t want to pay any service charges
    You are prepared to buy a new one
    You can’t accept the re-sell value of your broken iPod
    Rather than leave your iPod as paper-weight or throw it away.
    You can try the following, but again, only do it as your last resort and at your own risk.
    Warning !!!! – It may or may not manage to solve your problem, and with a risk that you may further damage your iPod, which end up as an expensive paper weight or you need to pay more higher repairing cost. Therefore, please re-consider again whether you want to try the next level
    Last Resort Level
    1. . Disconnecting the Hard Drive and battery inside the iPod – Warning !! Your iPod warranty will be waived once you open the iPod.
    In Hong Kong there are some electronic shops offering an iPod service for Sad iPod, the first thing they do is to open up the iPod’s case and disconnecting the battery and the Hard Drive from the main board of the iPod. Wait for 5-10 minutes and reconnecting them back. The reason behind which I can think of is to do a fully reset of a processor of the iPod. In case you want do it itself and you believe that you are good on fixing the electronics devices and have experience to deal with small bits of electronic parts, then you can read the following of how to open the iPod case for battery and HDD replacement (with Quicktimes)
    http://eshop.macsales.com/tech_center/index.cfm?page=Video/directory.html
    2.Press the reset button on the Hard Drive inside the iPod – Suggestion from Kill8joy
    http://discussions.apple.com/thread.jspa?messageID=2438774#2438774
    Have I tried these myself? No, I am afraid to do it myself as I am squeamish about tinkering inside electronic devices, I have few experiences that either I broke the parts (which are normally tiny or fragile) or failed to put the parts back to the main case. Therefore, I agree with suggestion to have it fixed by a Pro.
    2. Do a search on Google and some topics on this discussion forum about “Sad iPod”
    Exclamation point and folder and nothing else
    Spank your iPod
    http://www.youtube.com/watch?v=3ljPhrFUaOY
    http://discussions.apple.com/thread.jspa?messageID=3597173#3597173
    Exclamation point and folder and nothing else
    http://discussions.apple.com/thread.jspa?messageID=2831962#2831962
    What should I do with my iPod? Send it or keep it?
    http://discussions.apple.com/thread.jspa?threadID=469080&tstart=0
    Strange error on iPod (probably death)
    http://discussions.apple.com/thread.jspa?threadID=435160&start=0&tstart=0
    Sad Face on iPod for no apparent reason
    http://discussions.apple.com/thread.jspa?threadID=336342&start=0&tstart=0
    Meeting the Sad iPod icon
    http://askpang.typepad.com/relevanthistory/2004/11/meeting_thesad.html#comment-10519524
    Sad faced iPod, but my computer won’t recognize it?
    http://discussions.apple.com/thread.jspa?messageID=2236095#2236095
    iPod Photo: unhappy icon + warranty question
    http://discussions.apple.com/thread.jspa?messageID=2233746#2233746
    4th Gen iPod Users - are we all having the same problem?
    http://discussions.apple.com/message.jspa?messageID=2235623#2235623
    Low Battery, and clicking sounds
    http://discussions.apple.com/thread.jspa?messageID=2237714#2237714
    Sad faced iPod, but my computer won’t recognize it
    http://discussions.apple.com/thread.jspa?messageID=2242018#2242018
    Sad iPod solution
    http://discussions.apple.com/thread.jspa?threadID=412033&tstart=0
    Re: try to restore ipod and it says "can't mount ipod"
    http://discussions.apple.com/thread.jspa?threadID=443659&tstart=30
    iPod making clicking noise and is frozen
    http://discussions.apple.com/thread.jspa?messageID=2420150#2420150
    Cant put it into disk mode
    http://discussions.apple.com/thread.jspa?messageID=3786084#3786084
    I think my iPod just died its final death
    http://discussions.apple.com/thread.jspa?messageID=3813051
    Apple logo & monochrome battery stay
    http://discussions.apple.com/thread.jspa?messageID=3827167#3827167
    My iPod ism’t resetting and isn’t being read by my computer
    http://discussions.apple.com/thread.jspa?messageID=4489387#4489387
    I am not suggesting that you should follow as well, but just read them as your reference. You are the person to make the call.
    Finally, I read a fair comments from dwb, regarding of slapping the back of the iPod multiple times
    Quote “This has been discussed numerous times as a 'fix'. It does work, at least for a while. In fact I remember using the same basic trick to revive Seagate and Quantam drives back in the mid to late 1980's. Why these tiny hard drives go bad I don't know - could be the actuator gets stuck in place or misaligned. Could be the platter gets stuck or the motor gets stuck. 'Stiction' was a problem for drives back in the 80's. Unfortunately the fix can cause damage to the platter so we temporarily fix one problem by creating another. But I know of two instances where a little slap onto the table revived the iPods and they are still worked a year or more later.”UnQuote

  • I have a Photosmart 6510e that will only print after I shut printer off and then restart..

    After setting up my 6510e photosmart all computers are able to print ---laptop, netbook and my iPhone can eprint.  However, my desktop PC will only print once the printer sleeps (white light is dim) after I completely shut off the printer and then restart it.   I have updated drivers and software.  The message comes up "Unable to Communicate with Printer." 

    I have the same problem - I bought the 6510 printer yesterday and it seemed to connect wirelessly to my PC and shows as the default printer ok but when I try to print I get the message 'unable to communicate wirh printer'. I troubleshoot and am advised to switch on printer (it is already on) but when I switch it off and then on again the printing starts Ok. Very annoying and not what I had hoped for.....

Maybe you are looking for

  • Deleting Loops

    May someone please tell me how to delete the loops in Garageband that came with Soundtrack Pro? The the thing is, I uninstalled Soundtrack pro and it's loops. But Garageband still has SP's loops in the loop browser, but the loops are gone. Poof! Not

  • The file should be in XML-BURSTING-FILE format.

    I'm gettting an error when I try to upload my xml bursting control file for my oracle report that has an rtf template defined. The error message says"The uploaded file MT_RAXINV.xml is invalid. The file should be in XML-BURSTING-FILE format." and my

  • How can i wrote configuration file in Log4j

    iam new log4j .i have seen one small programme in log4j examples folder ..i e. shown below Sort.java ===== package examples; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Logger; import org.apache.log4j.Priority; Example code

  • Firefox 4 Crashes while toggling between multiple open profiles (Firefox has stopped working)

    So this problem just started occurring since I upgraded from firefox 3.6.5 to firefox4. Sometimes I need to have two separate firefox profiles open at the same time. This is accomplished by making a second shortcut to your firefox.exe with the switch

  • How can configure scope options in dhcp server

    Good Night Partners. I need configure scope options in dhcp server on mac mini. i dont know how to do. its my first mac and i confuse. Can anybody help me please.