• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet gives Flickering

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!!!

overrride update.draw an offline image that is buffer and then copy it.using drawImage method of graphics.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic