Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet initial painting - content overlap?

 
Ranch Hand
Posts: 837
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 4 small applets on a page that simply prints out the quadratic equation for values passed in. There are 4 applets on a page that have different values assigned. They display fine.... sometimes.... if I refresh or generate new numbers sometimes one applet looks as though it has numbers overlapping the new values. If I resize or drag the browser everything displays fine again - no need to refresh the browser or anything. It's as though old values or something are being overwritten by the new or something similar is happening. What should I include in the paint method of the JPanel that might help clear the applet before initial painting happens..... if anything? Thanks.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing your code I can only guess what you are doing.

First of all you shouldn't be overriding the paint() method, you should be overriding the paintComponent() method instead. This won't solve your current problem but it is the correct way to paint on swing components and it may well prevent other problems arising so rename your paint() method to the paintComponent().

If your panel is not being cleared properly starting the paintComponent() method with super.paintComponent() may well solve your problem.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic