• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFrame repaints but does not change visually

 
Oleg Shubin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
** Uups, looks like I've posted on the wrong forum! Needs to be in Swing / AWT / SWT **

Although that might seem to be a beginner's problem I'm having it in quite an unusual context.

I've got a JFrame (Swing component) all of whose children are AWT Components. Those Components (Canvas, in fact) are displaying buffered images that are concurrently updated by other threads. A java.util.Timer is repainting the frame at fixed rate. Although I see that the all the components are being painted over and over (a message is printed from one of the component's paint() method) the JFrame itself does not change visually until OS requests repainting (e.g. I change the size of the window).

All the Swing-related activities are performed from the AWT event dispatching thread; JFrame is repainted using frame.repaint().

Unfortunatly I cannot provide the actual code here because it is linked to my entire project, so here is a simplified version:

Why do I only use Swing for the frame? Well, at first I wanted to make an AWT application (less useless (in my case) processing, amiright?) but it turned out I needed double bufferisation in order to reduce artifacts on screen updates.

Thanks in advance
 
Paul Clapham
Sheriff
Posts: 21886
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are problems which arise when you mix Swing and AWT components in the same application, most of which involve components not displaying correctly. Looks like you might be encountering that. Just use the Swing components already.
 
Oleg Shubin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:There are problems which arise when you mix Swing and AWT components in the same application, most of which involve components not displaying correctly. Looks like you might be encountering that. Just use the Swing components already.


Well, that turned out to be the problem. However, that's strange: as I know, Swing is based on AWT, moreover, it is actually just a bunch of (complex) utilities added to AWT; shouldn't it be backwards-compatible, especially if, IMHO, I do not use any of those utilities?

Anyway, thank you for helping. I'll be more careful with mixing libraries next time.
 
Paul Clapham
Sheriff
Posts: 21886
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oleg Shubin wrote:However, that's strange: as I know, Swing is based on AWT, moreover, it is actually just a bunch of (complex) utilities added to AWT;


Well, no, that isn't how it is at all. Swing was a rewrite of AWT using a completely different architecture at the lower levels, and (yes) with a lot more useful features. Nowadays (meaning at any time since 2000) there's no reason to use AWT any more as Swing is more powerful and flexible. Actually "no reason" isn't quite right -- if you want to write an AWT application for your personal interest you could certainly do that, but there's no technical reason to use AWT at all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!