Java paint(), repaint() kerdes

Fórumok

Epp egy vizualizacios progit irok, de problemaba utkoztem.
A rajzolashoz egy sajat JComponent-et csinaltam, atirt paint()-el.
Viszont a szamolas kozepette hiaba hivom meg a repaint()-et, a paint() soha nem hivodik meg, csak amikor mar vege a szamolasnak.

Biztos vagyok benne, hogy van erre egy standard, jo megoldas (mondjuk Thread-ekkel).

Kerlek, segitsetek!

Hozzászólások

App-triggered painting
An app-triggered painting operation takes place as follows:

  1. The program determines that either part or all of a component needs to be repainted in response to some internal state change.
  2. The program invokes repaint() on the component, which registers an asynchronous request to the AWT that this component needs to be repainted.
  3. The AWT causes the event dispatching thread to invoke update() on the component.
    NOTE: If multiple calls to repaint() occur on a component before the initial repaint request is processed, the multiple requests may be collapsed into a single call to update(). The algorithm for determining when multiple requests should be collapsed is implementation-dependent. If multiple requests are collapsed, the resulting update rectangle will be equal to the union of the rectangles contained in the collapsed requests.
  4. If the component did not override update(), the default implementation of update() clears the component's background (if it's not a lightweight component) and simply calls paint().

Ezt olvasd talán van benne valami hasznos.

Nem lehet, hogy a swing threadben van a számolás is?