Swing/AWT on a custom display? (catch repaint() calls)

R

Ralf

Hi,

I have implemented a Java interface to draw on a custom display (160x43
black and white LCD). The drawing is done via a normal Graphics class
to a BufferedImage, and the data is then copied to the LCD on request.

Now I want to display a normal AWT or Swing component on the LCD. I can
do this by simply calling the paint() method of the component with my
Graphics object. The problem is to update the display automatically
whenever a component changes. In other words, i want to know whenever
the component's repaint() method is called, and then call the paint()
method myself.

With Swing components, I can replace the default RepaintManager with my
own, and use it to catch the repaint calls. However, I have 2 problems
with this:
- RepaintManager.setCurrentManager() replaces the RepaintManager for
all components, not just the ones I want to display.
- The RepaintManager's paintDirtyRegions() method only get's called
when the component is visible on an actual screen. This means that I
can display a component both on the screen and my display, but not only
on the display, as I want to.

The main problem seems to be that if a component is not visible on the
screen, the repaint method doesn't really do anything. I've tried
adding the component to a parent Container, and override the
container's repaint() method, but it isn't called either when the
component is not visible.

This might also be something to do with peers. I've tried implementing
my own peers, but it is ugly, undocumented and discouraged by the
javadocs, and not really what I want to do anyway.

I've also tried implementing my own GraphicsDevice, but it doesn't seem
to have any methods for catching the repaint calls.

The only option that seems to work at the moment is to just refresh the
display every few milliseconds, regardless whether it changed, but it's
not a very nice solution.

Does anyone have any other ideas for catching repaint() methods?

Ralf
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top