• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet gives Flickering

 
Aayush Patel
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had written in programme using swing..now when i run through normail applet then it will gives me flickering...i had used Applet and Panel instead of JPanel and JApplet...If i m using Swing then it will run fine...but gives me problem in applet...and i have to run that programme in Browser...so i must have to use AWT instead of Swing..So please help me in this regards...
 
java puneri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
If you are using AWT instead of SWING then you have to use
double buffering which avoids flickering.
little bit more:-
1.Draw whatever you wanto on offline Image object.
2.When you are done show that Image object on the applet canvas
Cheers
PuneGuy !
 
Aayush Patel
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
sorry i m not getting your answer..can u explained me in detail ...if u so then its good for me...
 
java puneri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Following code is for achiving double buffering !
----------------------------------------------------------------
code starts
Image buffer;
Graphics g1;
public void update(Graphics g){
paint(g);
}

public void paint(Graphics g){
//Draw the flickering code
drawExample();
// Draw completed buffer to g
g.drawImage(buffer,0,0,this);
}
public void drawExample(){
buffer = createImage(APPLETWIDTH,APPLETHEIGHT);
g1 = buffer3.getGraphics(); /// Offline Image drawing
g.setColor(whateverulike);
g.drawLine();
g.drawRect();
. /// Carry on drawing all here
.// draw entire stuff that u are drawing in paint method
.
// u r done here drawing all stuff
return;
}
Code ends !!!
-----------------------------------------------------------

I tried to explain what I had understood from your post.
If still have problem then feel free to ask !
or better you explain your problem in detail !
Cheers
PuneGuy
 
sharad goswami
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!!!

overrride update.draw an offline image that is buffer and then copy it.using drawImage method of graphics.
 
Charlie Boss
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i'm having the same flickering problem with my swing applet.. i'm not drawing any shapes ("g.drawLine(), g.drawRect()")etc but i'd like to know how to draw my JComponents (JPanels, JButtons)etc.. thanks
 
Shaunak Desai
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I am also having flickering problems. I have used swing applets. When I scroll these applets in browser, they flicker like hell. I am still trying to figure out the reason behind this.
 
Aayush Patel
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi shaunak,
in applet whenever we drawn component it will draw directly on screen..while in swing it will create one canvas (screen)automatically and drawn component on that screen..so in awt we are facing flickering problem..and we had solved it through double buffering...so check it out double buffering
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic