When resize window, the picture will disappear

my code is :
G11_G3(int x, int y, int w, int h) {
     super("G11_G3");     
     this.setBounds(x, y, w, h);
     this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     this.setVisible(true);
     content=this.getContentPane();
     MouseInputListener myLis=
     // this.new MouseInputListener() {   // rejected syntax
     new MouseInputListener() { // anonymous inner class
          public void mouseClicked(MouseEvent e) {
          public void mouseEntered(MouseEvent e) { 
          public void mouseExited(MouseEvent e) {
          public void mousePressed(MouseEvent e) {
               Graphics g=content.getGraphics();
               g.drawRect(e.getX()-50,e.getY()-25,100,50);
               p.add( new Point(e.getX()-50, e.getY()-25) );
               g.drawRect(e.getX()-25,e.getY()-50,50,100);
               p.add( new Point(e.getX()-25, e.getY()-50) );
          public void mouseReleased(MouseEvent e) { 
          public void mouseDragged(MouseEvent e) { 
          public void mouseMoved(MouseEvent e) { 
     content.addMouseListener(myLis);
     content.addMouseMotionListener(myLis);
when I run it, and I clicked the screen, it will draw an image for me, but when I resize the window, it will disappear.
what can I do to keep the image on the screen.
thx be4!

please use code tags so you code is formatted.
you need to put your painting code inside the paint method. This is called when the object it firs drawn and it is triggered for various other reasons while the window is running (like on resize).
I suggest you place some kind of variable in the class that tells the paint method where to draw your rectangle, update this on a mousepressed action and call repaint() . then just extend the paint method, call super.paint() and draw your rectangle.
hope this helps,
Ken

Similar Messages

  • When hovering cursor over file edit ect the names will disappear

    recently installed a new version of avira from cnet download.com after which when hovering cursor over file edit history bookmark tools or help the names will disappear from firefox. Also same thing occurrs in bookmarks list and on toolbar names.pc will lockup and need hardware reboot to clear?
    This problem has occurred on another machine of mine running windows XP on virgin broadband.

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    >In Firefox 4 Safe mode also disables plugins (Tools > Add-ons > Plugins) and hardware acceleration (Tools > Options > Advanced > General)

  • When I take a picture with my iPhone 5s and afterward turn it laterally, the picture will not turn. It used to all the time. How do I fix this?

    When I take a picture with my iPhone 5s and afterward turn it laterally, the picture will not turn. It used to all the time. How do I fix this?

    Hi there dworthen,
    It sounds like you are experiencing issues when trying to rotate your display. I would recommend taking a look at the troubleshooting steps found in the article below.
    iOS: Screen does not rotate
    http://support.apple.com/kb/TS3805
    -Griff W.

  • I'am trying to copy pictures from Print Shop to send as a e-mail, not an attachment but putting the picture in the actual e-mail. The lettering from the Print Shop document will copy and paste but the picture will not. How do I get it in the email?

    I create a document in Print Shop Delux download pictures from that program to make a flyer. I'am trying to send the flyer to someone and they do not want it as an attachment so I'd like to send it in the body of the e-mail. They lettering on the flyer copy and paste but the picture will not copy and paste. How do I get the picture to copy and paste in the body of the e-mail. I can't copy and paste the whole document because in did a insert text box for the picture.

    Click the image , hold your mouse button, drag it and bring it to Firefox window from task bar below and release it into the body of your e-mail.Works on Gmail, Yahoomail , Hotmail....May not work on other e-mail service providers.

  • My apple tv, when connected to the television, will only show an itunes icon with a usb cord

    My apple tv, when connected to the television, will only show an itunes icon with a usb cord. I don't know whay to do?

    Don Sullivan wrote
    "Same thing just happened to  me. There was a software update available, it installed the update and then died with that visual on the screen. Reset doesn't work and it won't even show up in iTunes to try and do anything with it. I think they just bricked it on me."
    Same thing just happened to me too...
    I did an update a couple of days ago: and it seemed to be working fine. Just did another update today: got a flashing light, sometimes a blank screen, and sometimes the itunes logo / USB symbol...

  • When using FaceTime the picture is delayed and goes black ever since I updated to iOS6.0.1???

    Since I updated to iOS 6.0.1 when using FaceTime the picture is delayed and goes black???

    The <b>authorize<i></i>.net</b> website is using autocomplete=off to prevent Firefox from saving and filling the name and password.
    You can remove autocomplete=off with a bookmarklet to make Firefox save the name and password.
    *http://kb.mozillazine.org/User_name_and_password_not_remembered
    *https://support.mozilla.org/kb/Username+and+password+not+remembered

  • I'm having trouble importing pictures from the internet....when I drag the picture to the icon, it gives me the option to import all duplicates. Even when I click "NO", it STILL imports every picture I have imported AGAIN, including the new one! WHY??

    I'm having trouble importing pictures from the internet....when I drag the picture to the icon, it gives me the option to import all duplicates. Even when I click "NO", it STILL imports every picture I have imported AGAIN, including the new one! WHY??

    carolinechx wrote:
    i know the description may be a little bit too confusing
    Mostly because you are not using any capital letters or paragraph returns and your post is difficult to read.

  • HT4858 with photo stream on and importing pictures from your camera into your Ipad - after 30 days the pictures will be removed from photo stream, but will the pictures still be in your Ipad ? andy

    with photo stream on and importing pictures from your camera into your Ipad - after 30 days the pictures will be removed from photo stream, but will the pictures still be in your Ipad ? andy

    To my knowledge, pictures in photo stream stay there untill there is more than 1000 of them, then after that the oldest ones are removed from photo stream.  If your photos have synced to your devices via photo stream or manual syncing they will be there until you elect to delete them.

  • Why the game: Injustice, when play with the challenge will direct close the game? Please fix it.

    Why the game: Injustice, when play with the challenge will direct close the game? Please fix it.

    You need to speak to the developer. They should have some sort of contact link on their iTunes page.  This is just a user to user tech support forum, no one here has any sort of control over apple or what developers do.
    The game developer may also have some sort of fix on their site, so look there.

  • TS3367 When on FaceTime, the screen will suddenly freeze for a few seconds as well as the audio. This has happened to eThis veryone I have talked to on Facetime. Any suggestions?

    When on FaceTime, the screen will suddenly reeze for a few seconds as well  as the audio. This happened to everyone I have talked to on FaceTime. Any suggestions to keep this from happening?

    Hey everyone in Apple world!
    I figured out how to fix the flashing yellow screen problem that I've been having on my MBP!  Yessssss!!!
    I found this super handy website with the golden answer: http://support.apple.com/kb/HT1379
    I followed the instructions on this page and here's what I did:
    Resetting NVRAM / PRAM
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    I went through the 6 steps above twice, just to make sure I got rid of whatever stuff was holding up my bootup process.  Since I did that, my MBP boots up just like normal.  No flashing yellow screen anymore!!   
    (Note that I arrived at this solution when I first saw this page: http://support.apple.com/kb/TS2570?viewlocale=en_US)
    Let me know if this works for you!
    Elaine

  • When I try to access a picture from i photo the picture will come up and then quickly the screen goes black and there is a white exclamation mark.  Also when using faces and scrolling down pictures some disappear very quickly after a brief look.

    When using i photo and trying to pull up individual photos - the photo will appear and quickly disappear only to be replaced by a black screen with a white explanation mark.  This happens with all of my photos.  Has anyone had this problem and if so what can be done to fix it.  I did not select this graphic to be added to my i photo pictures - the blace sign with the white explanation mark.  Also, when scrolling down photos in faces some of my pictures disappear after a quick view. 
    Thanks for any help you can provide.  It seems like something has gotten into my i photo picture account?

    The ! turns up when iPhoto loses the connection between the thumbnail in the iPhoto Window and the file it represents.
    What version of iPhoto? Assuming 09 or later...
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • HT1688 When I receive a picture or take one, I use to be able to turn the phone to fill the screen now the pictures will not turn when I rotate phone iPhone 4. Help please

    When I first got my iPhone when I received a picture or took one I could turn phone and picture would turn to fill the screen. It will not do this anymore, is there a setting I need to correct? Ty

    Rory,
    I have the same issue, but my screen is not locked as you instructed Little5571.  Neither images or webpages rotate to landscape when I turn my phone.  Do I need to do a factory reset and restore to fix this issue?
    Sstrynar

  • I saved images from an imessage.  now when I open Imessage, the pictures will not go away. When I press "done" the pictures remain. Cannot send a message

    I saved images from an imessage.  Now when I open Imessage, the pictures are displayed on the screen.  When I click on "done" the images do not go away.
    Therefore, I cannot send a message.

    Quit the app completely and try again. Go to the home screen first by tapping the home button. Double tap the home button and the task bar will appear with all of your recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Or try this.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • TS3474 The ipod display will not orient when turn...picture will move when turned.  Thank you.

    I've reset the ipod nano..downloaded the software again and still the display will not turn when the ipod is turned.  I don't know what else to do.  Does this ipod need to be sent back to Apple?  It's 6 months old.  Any other suggestions?  It's a 6th generation nano bought as a bundle with a armband and changer for Christmas 2011from Best Buy.

    So you placed two fingers such as your thumb and index finger in a pinchlike fashion on the Nano's display and turned them clockwise and counterclockwise and nothing happened?
    If so, you have a hardware issue, meaning you'll want to have the iPod serviced or replaced.
    B-rock

  • When exporting an album to Snapfish or Facebook, not all the pictures will transfer.  The same photos are missing in each export.  Help.

    I have version 10.7.1 with 4 GB's.  All software is updated.  Not all the jpegs will transfer to a web site.  And it's the same pix not exporting, not a random selection each time.  All have a rating of "not rated or better".

    Are the images inside stacks?  Only the Stack Pick goes over.
    DLS

Maybe you are looking for

  • How can I convert an .AVI movie file to get it into i-movie for editing?

    I have downloaded the VLC media player which will open and play the .AVI files from a video camera (RCA Small wonder high def digital camcorder EZ229HD). Now I need to be able to convert these movies (which will only open and play after dragging them

  • Comparing successive years in a report

    Hello! I've tried to find answers to my dilemma, but so far either I have come up short, the instructions were not quite what I was looking for... or I just didn't understand the instructions. My goal is to create a report that looks a bit like this:

  • Nginx client_ip in log file, with ssh -R Port forwarding

    Hi, everyone! First, I run a nginx server M1 (in my offce)  behind a router R1 and M1's IP addr is 192.168.5.126. I set nginx's log format like this: log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$

  • First Generated Bill DOUBLE what I expected!!!

    I just received my first generated bill.  It is DOUBLED what I expected!!!  I changed plans in the middle of the month to increase my calling minutes and I added four "friends and family."  They added $120.00 in "Monthly Access Fees."  This is after

  • Illustrator: Expanding Blend Mysteriously Changes Shape

    Hi all! My name is Alexis I have a blending problem (hiiii Alexis...). Okay, seriously, I've used the blend tool to make a series of lines between two other lines; I need to expand everything so that the whole thing becomes a fill-only object (no str