Results 1 to 6 of 6
  1. #1
    cl2606 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default screen not clearing during resize

    Hello. I'm messing around with applets and wrote a simple program that calculates the coordinates for an airfoil from an airfoil number and then draws the airfoil to the screen. The program works fine, except when I maximize the applet window the old drawing of the airfoil is still there. If I click and drag to resize the window, the applet continually redraws and one big mess is made.

    Here is the odd thing. All this is happening on a brand new 64 bit system running Win7. On my old 32 bit, WinXP the applet works fine, that is when the applet window gets resized the old drawing is no longer there and the new one is drawn with no trace of the old one. Both systems are running Java 6 with update 29.

    I originally had Java 7 running on the Win7 computer but thought it might be Java 7 so I went back to Java 6 but the same thing happens.

    Any thoughts?

    Thanks

    cl2606

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: screen not clearing during resize

    Is this a Swing JApplet? An AWT Applet? If the former, does your paintComponent method have a call to the super.paintComponent method? If the latter, does your paint method have a call to super.paint() in it?

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

  4. #4
    cl2606 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Re: screen not clearing during resize

    It is a JApplet. I didn't have super.paintComponents() in there, but I added it in and it works, so thank you. I modeled my applet off of Java Trails ShapesDemo2D and it didn't have it in there either.

    So can you explain why it works on the 32-bit machine without the paintComponents() and it doesn't work on the 64-bit. One other thing the 32-bit is running Eclipse Helio and the 64-bit is running Eclipse Indigo. I have don't know if that should make a difference or not but it seems odd that it works on one machine and not the other.

    Thanks again.

    cl2606.

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: screen not clearing during resize

    It should NOT be super.paintComponents(). It is super.paintComponent() (without the "s").

    Did you read the tutorial? It explains the proper way to do painting. If you use proper coding techniques it should work on all machines and platforms. If you don't you will get potentially get random errors.

    I would expect it doesn't work on 32bit machines either, that is why Pete was able to make the guess he did, because your symptom is a common result of forgetting the super.paintComponent().
    Last edited by camickr; 11-23-2011 at 06:27 AM.

  6. #6
    cl2606 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Re: screen not clearing during resize

    camikr,

    Thanks for the reply. No, I didn't read the tutorial. I modeled mine off of a Java Trails program, ShapesDemo2D, which I found here, http://docs.oracle.com/javase/tutori...pesDemo2D.java. They don't use super.paint or super.paintComponent either. And their program does the same thing that I was describing earlier. It works fine on the 32 bit system but not the 64 bit. I will definitely read the trail though.

    And as far as the super.paintComponent vs super.paintComonents, with an "s", was that I got the following error "The method paintComponent(Graphics) is undefined for the type JApplet" for paintComponent.

    The ShapesDemo2D does various shapes. Mine does two things, draws a horizontal line in the middle of the screen, then uses coordinates from an array and creates a GeneralPath and then draws that.

    I admit I was doing it quickly and that it probably was not be the proper way.

Similar Threads

  1. Having problems clearing an arrayList
    By zenitis in forum New To Java
    Replies: 8
    Last Post: 05-05-2011, 10:29 PM
  2. Dialog box clearing graphics
    By theborland in forum Java Applets
    Replies: 1
    Last Post: 12-03-2010, 08:27 PM
  3. clearing/reseting text fields in GUI
    By reis3k in forum New To Java
    Replies: 1
    Last Post: 12-02-2010, 07:12 PM
  4. emptying/clearing an array
    By i8java in forum New To Java
    Replies: 2
    Last Post: 08-09-2010, 02:39 PM
  5. Help Clearing BufferedImage
    By ketann in forum Java 2D
    Replies: 19
    Last Post: 03-29-2010, 08:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •