Results 1 to 6 of 6
- 11-23-2011, 03:25 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
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
-
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?
- 11-23-2011, 03:30 AM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: screen not clearing during resize
- 11-23-2011, 03:48 AM #4
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
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.
- 11-23-2011, 05:24 AM #5
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
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 05:27 AM.
- 11-23-2011, 11:55 AM #6
Member
- Join Date
- Nov 2011
- Posts
- 3
- Rep Power
- 0
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
-
Having problems clearing an arrayList
By zenitis in forum New To JavaReplies: 8Last Post: 05-05-2011, 09:29 PM -
Dialog box clearing graphics
By theborland in forum Java AppletsReplies: 1Last Post: 12-03-2010, 07:27 PM -
clearing/reseting text fields in GUI
By reis3k in forum New To JavaReplies: 1Last Post: 12-02-2010, 06:12 PM -
emptying/clearing an array
By i8java in forum New To JavaReplies: 2Last Post: 08-09-2010, 01:39 PM -
Help Clearing BufferedImage
By ketann in forum Java 2DReplies: 19Last Post: 03-29-2010, 07:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks