🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.java
3 messages
3 total messages Started by Lucky Sun, 24 Jul 2011 11:25
obrazek mruga, problem z double buffering?
#152723
Author: Lucky
Date: Sun, 24 Jul 2011 11:25
39 lines
1726 bytes
Witam,

Mam cos takiego:

public class Chart extends JPanel {
     private Image dbImage;
     Graphics dbg = null;
...
    @Override
     public void paint(Graphics g) {
         paintComponent(g);
     }


     @Override
     public void update(Graphics g) {
         if (dbImage == null) {
             dbImage = createImage(this.getSize().width, 	 
this.getSize().height);
             dbg = dbImage.getGraphics();
         }
         dbg.setColor(getBackground());
         dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
         dbg.setColor(getForeground());
         paint(dbg);
         g.drawImage(dbImage, 0, 0, this);
     }

     @Override
     public void paintComponent(Graphics graph) {
	// tutaj jest rysowanie obrazka na podstawie danych zapisanych w tablicy
     }

Dane w tablicy sa aktualizowane w petli, srednio kilkanascie razy na 
sekunde.

Ciagle mruga. Co robie zle?
Dzieki,
L
Re: obrazek mruga, problem z double buffering?
#152724
Author: Paweł Andziak
Date: Mon, 25 Jul 2011 06:06
8 lines
1300 bytes
Nie rysuj na obiekcie Image, który właśnie wyświetlasz. Przygotuj całą
grafikę na innym obiekcie i podmieniaj aktualnie wyświetlany Image.
Dodatkowo możesz przy rysowaniu użyć BufferStrategy:

http://download.oracle.com/javase/tutorial/extra/fullscreen/bufferstrategy.html

-- 
ganda
Re: obrazek mruga, problem z double buffering?
#152725
Author: Lucky
Date: Tue, 26 Jul 2011 19:40
11 lines
1334 bytes
On 25/07/2011 07:06, Paweł Andziak wrote:
> Nie rysuj na obiekcie Image, który właśnie wyświetlasz. Przygotuj całą
> grafikę na innym obiekcie i podmieniaj aktualnie wyświetlany Image.
> Dodatkowo możesz przy rysowaniu użyć BufferStrategy:
>
> http://download.oracle.com/javase/tutorial/extra/fullscreen/bufferstrategy.html

Dzieki, okazalo sie, ze problem byl zupelnie gdzie indziej, juz to 
rozwiazalem.
Pozdrawiam,
L
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads