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

Discussion in 'Java' started by Ralf, Sep 7, 2006.

  1. Ralf

    Ralf Guest

    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
    Ralf, Sep 7, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    newbie: awt repaint

    Guest, Aug 7, 2003, in forum: Java
    Replies:
    2
    Views:
    708
    Guest
    Aug 7, 2003
  2. Robert Mark Bram
    Replies:
    2
    Views:
    5,945
    Robert Mark Bram
    Dec 11, 2003
  3. mkrause
    Replies:
    0
    Views:
    663
    mkrause
    May 6, 2005
  4. MaciekL
    Replies:
    1
    Views:
    862
    supercalifragilisticexpialadiamaticonormalizeringe
    Aug 5, 2011
  5. MaciekL
    Replies:
    2
    Views:
    1,734
    Ian Shef
    Aug 5, 2011
Loading...

Share This Page