Help with BufferedImage - Graphics updating

Hello All-

I will try to explain the best I can, still new to Java2D so little confused

Hopefully the explanation makes a little bit of sense....

I have a tabbedPane, one tab with no graphics and the other tab full of graphics

The tab with the graphics on it is basically a bunch of rectangles that will change color depending on real time data I am pulling from a Mysql DB

For sake of performance I only want to have to repaint those rectangles when the data from the DB changes (i.e. repaint the rectangles when the bit changes from 1=good to 0=bad)

Any help on how to start implementing this would be absolutely wonderful

or if I could explain something any better please ask.

Thank you in advance

Janduzerbots

[774 byte] By [janduzerbots] at [2007-9-30 20:19:19]
# 1

You could check out the java.util.TimerTask class... you could set it up so that every ten seconds (or whatever), your TimerTask checks the latest values in the database and updates your graphics accordingly. It's not truly real-time, though, since you have to poll the database every X seconds.

scorbett at 2007-7-7 1:04:20 > top of Java-index,Security,Cryptography...
# 2
I wouldn't worry about the efficiency of repainting this rectangle-filled component, at first. If it really is expensive to redraw, it sounds like a good candidate for double-buffering in a BufferedImage.
DrLaszloJamf at 2007-7-7 1:04:20 > top of Java-index,Security,Cryptography...
# 3

Thank you very much!!! for the help on where to get myself started

but as I look into the DoubleBuffering

I run into a little bit of confusion because of the two tabs

still a little new to the whole java 2D

Is it necessary to implement the graphics tab (vs the pure data tab)

in a separate class or inner class,

or is it easy enough to just apply all of the DoubleBuffering Image implementation

to the graphics panel and only the graphics panel without a separate class?

Thanx

-Janduzerbots

janduzerbots at 2007-7-7 1:04:20 > top of Java-index,Security,Cryptography...
# 4

If you're thinking of just grabbing the graphics image of some component on the fly for rendering, that

wouldn't work well. Here is a [url=http://forum.java.sun.com/thread.jsp?forum=54&thread=529542&start=5]link[/url] to some tips on doing your own drawing.

Again, yes, you may have to define your own component class. The only other alternative I can think of is to have a JLabel

that has an ImageIcon that holds your BufferedImage, and you update this by calling repaint after updating

the BufferedImage.

DrLaszloJamf at 2007-7-7 1:04:20 > top of Java-index,Security,Cryptography...