Very busy Swing/AWT thread

R

Ryan Phelps

If your swing thread is so busy redrawing one component (~125 repaint
requests/sec, only able to perform ~9 repaints/sec) what happens to
your swing widgets? My Swing widgets, buttons, menus, etc., don't
show up except under special circumstances.

Special circumstances are when they have focus and paint the little
dashed line around the button, or I click on their area and change
their state -- stuff like that. Essentially, there has to be
something that explicitly redraws the widgets in order for them to
show up. My custom widget shows up great, it's constantly redrawing.

My particular application is reading around 125 X-Y profiles from a
remote measurement device and displaying them in a home-grown graph
JComponent in an applet.

Thanks.
 
C

Chris Smith

Ryan said:
If your swing thread is so busy redrawing one component (~125 repaint
requests/sec, only able to perform ~9 repaints/sec) what happens to
your swing widgets? My Swing widgets, buttons, menus, etc., don't
show up except under special circumstances.

What does your code look like? I suspect that either the redrawing of
your custom component is not being done with repaint events as it
should, or your other components are broken in such a way that they
aren't trying to repaint. Repaint events should be queued and collapsed
in such a way that one component's constant desire to repaint shouldn't
prevent anyone else from doing so.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
K

Knute Johnson

Chris said:
What does your code look like? I suspect that either the redrawing of
your custom component is not being done with repaint events as it
should, or your other components are broken in such a way that they
aren't trying to repaint. Repaint events should be queued and collapsed
in such a way that one component's constant desire to repaint shouldn't
prevent anyone else from doing so.

In addition to what Chris said, 125 repaints per second is probably
eating up too much time. Unless you've got a really fancy monitor, it
isn't that fast anyway. So why not use something in the 25 to 30 per
second range? You will never be able to tell the difference looking at it.
 
R

Roedy Green

In addition to what Chris said, 125 repaints per second is probably
eating up too much time. Unless you've got a really fancy monitor, it
isn't that fast anyway. So why not use something in the 25 to 30 per
second range? You will never be able to tell the difference looking at it.

what if you wanted to repaint as fast as possible, while still letting
the rest of the app function?

How might you arrange things?

You would need some low priority thread to soak up all left over time.
It might use paintImmediately (swing thread only?), or toss repaints
into the queue and wait for completion before tossing another.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top