Swing & double buffer

Hello
My English abillity is very poor ... sorry
as I know Swing offer double buffer very easy and default
I check My application is offer double buffer (I check use isDoublebuffered())
and I draw my pic in JPanel
paint(Graphics g){
and I make update method
update (Grphaics g){
paint(g);
but my application flash and flicker...
How can I solve my problem?
What I do solve my problem?
plz help
have a nice day

paint(Graphics g){
and I make update method
update (Grphaics g){
paint(g);
}1. JComponent already has method update overridden to call paint -- you shouldn't override update.
2. Don't override paint, override paintComponent instead, usually like this:
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    //do your painting here:
}3. Swing components double buffer by default. You shouldn't have to use BufferedImages just to avoid flicker. Try to reduce your problem to a minimal example and post it.

Similar Messages

  • Still not understanding Swing Double buffering

    I'm writing a custom JComponent like
    class Custom extends JComponent {
    protected void paintComponent(Graphics g) {
           //slow complex routine
    }As the display does not often change I thought I could improve performance with my own off-screen rendering
    class Custom extends JComponent {
    private Image screenImage= null;
    private void doOffscreen() {
                BufferedImage backimage = defaultgc.createCompatibleImage(getSize().width, getSize().height);
                final Graphics2D g2 = backimage.createGraphics();
                 slow complex routine
                screenimage = backimage;
    protected void paintComponent(Graphics g) {
           super.paintComponent(g);
           if (screenimage != null) {
                g.drawImage(screenimage, 0, 0, null);
    }What does adding
    class Custom extends JComponent {
           public Custom() {
                setDoubleBuffering(true);
    }get me ? Or can I use the SWING double buffer to render to ?
    I'm guessing what it will do is render my screen image into yet another image and then switch this in.
    I feel I'm missing something :(

    I've run your code and it seems to work well,
    however it is in constant update mode where as my application usually only changes as a part of user interactionActually, that doesn't matter, since when you want the screen to update, you just call "repaint()" from any place that has visibility in your application. The real wonderful thing about offscreen rendering is: that when you have to have an update done, it paints immediately is a very optimized code--a one line paint/paintComponent routine, since the image is pre-rendered, no waiting.
    The offscreen rendering approach lends very well to animation loops, adhoc graphic updates, and pretty much any other animation schemes I've been able to come up with.
    There is really only one concern that I have in offscreen renderings: it is possible that you would be able to catch the offscreen image being rendered so only a partial image would be present on the screen. I cannot make it do this so I can notice it happen in any animation loop or continuous update scenario that I've been able to test.
    I can force it to happen noticeably in code if I purposefully artificially extend the animation times far beyond what they may normally take and unreasonably make multiple tick cycles to the animation and update delays. This is like running a film in ultra slow motion--frame by frame, but under normal conditions (full speed animations), I cannot force any noticeable flaw in the output of an offscreen rendering scheme.
    I've pumped that program that I posted up to 10,000 objects and it still ran--no flicker what so ever, but yes, it was a little jerky since I'm doing 1600x1200 and 10,000 images on a 2.4 GHz AMD under Solaris x64, but at the 1,000 object mark as posted, it works fine.

  • What is the best way to double buffer in this case and how to do it....

    currently I have
    public class Frame1 extends JFrame{
    //inside this class I call up circle class, rectangle class, etc.... to draw
    }I am making a "paint" program, and I have individual classes to handle the paint methods heres an example:
    abstract public class Shape {
        public Shape() {
        public abstract void draw(Graphics g, Color c, int x, int y, int width,int height);
    }and then....
    public class Circle extends Shape{
        public Circle() {
        public void draw(Graphics g, Color c, int oldx, int oldy, int newx, int newy) {
            g.setColor(c);
            g.drawOval(Math.min(oldx, newx), Math.min(oldy, newy), Math.abs(oldx - newx), Math.abs(oldy - newy));
    }There is also a Rectangle class, line class.... etc! So my question to you is the following... what is the best way to implement double buffer in the individual classes? And how to do it?? And also.... the drawings should be kept inside a jPanel.
    Any bit of help is much appreciated Thank you!!

    You don't need to do double-buffering. Swing
    components are double-buffered by default. Just make
    sure you override paintComponent() and not paint().
    And even if you had to, why would there be any
    difference in implementation for your classes whether
    they paint to on- or off-screen graphics?I need to override paintComponent()? what if I don't...
    I am using JBuilder2005 and they automate somethings for me. So thats how they did it when they created the application they did this....
    public class Frame1 extends JFrame{
    /*** all my code here***/
    public class Application1 {
        boolean packFrame = false;
         * Construct and show the application.
        public Application1() {
            Frame1 frame = new Frame1();
            // Validate frames that have preset sizes
            // Pack frames that have useful preferred size info, e.g. from their layout
            if (packFrame) {
                frame.pack();
            } else {
                frame.validate();
            // Center the window
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension frameSize = frame.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            frame.setLocation((screenSize.width - frameSize.width) / 2,
                              (screenSize.height - frameSize.height) / 2);
            frame.setVisible(true);
            try {
                jbInit();
            } catch (Exception ex) {
                ex.printStackTrace();
         * Application entry point.
         * @param args String[]
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.
                                                 getSystemLookAndFeelClassName());
                    } catch (Exception exception) {
                        exception.printStackTrace();
                    new Application1();
        private void jbInit() throws Exception {
    }

  • Double Buffer

    Hi all,
    I've just written this Digital Clock in Java and I'm trying to add a double buffer to it to stop it flickering however I get 4 errors when I try to compile it. Here is the code:
    (START OF CODE)
         import java.awt.*; //puts in abstract windows toolkit to get output on screen
         import java.util.*;
         import java.applet.Applet;
         import java.awt.event.*;
         //<applet code="DigitalClock.class" width=400 height=400></applet> //displays applet without needing to create HTML file
         public class DigitalClock extends Applet implements ActionListener, Runnable //listen for action events
         Image myimage,buffer;
         Graphics doublebuffer;
         private javax.swing.Timer timer; //implements timer
         public void init() {
    timer = new javax.swing.Timer(1000, this);
    timer.setInitialDelay(0);
    timer.start();
         buffer = createImage(width,height);
         doublebuffer = buffer.getGraphics();
         public void paint(Graphics g) //states that the code below will paint objects onto the applet
         g.setColor (Color.white); //sets colour to white
         g.drawRect(130, 78, 120, 30); //rectangle shape surrounding digital clock
         g.setColor (Color.darkGray); //sets colour to grey
         g.fillRect(132, 80, 117, 27); //fills rectangle from code 2 lines up with colour grey
         setBackground(Color.black); //specifies background colour as black
         Calendar myCal = new GregorianCalendar();
         myCal.set(1956, Calendar.MARCH, 17); //
         of myCal.setTime(myCal2.getTime());
         myCal.setTime(new Date());
         int year = myCal.get(Calendar.YEAR); int mnth = myCal.get(Calendar.MONTH) + 1;
         int DATE = myCal.get(Calendar.DATE); System.out.println(DATE + "." + mnth + "." + year);
         myCal.add(Calendar.YEAR, 1);
         DATE myDate = myCal.getTime(); System.out.println(myDate);
         GregorianCalendar cal = new GregorianCalendar(); //tells program to implement the a new Gregorian Calemder in order to display a date or time
         doublebuffer.setFont(new Font("Arial", Font.BOLD,20)); //sets font to arial, bold style, and size 20
         doublebuffer.setColor (Color.white); //sets colour to white
    doublebuffer.drawString(cal.get(Calendar.HOUR_OF_DAY) + " : " + //examines windows clock to get current hour
    cal.get(Calendar.MINUTE) + " : " + //examines windows clock to get current minute
    cal.get(Calendar.SECOND), 140, 100); //examines windows clock to get current second
         doublebuffer.setFont(new Font("Arial", Font.BOLD,15)); //sets the font to arial, bold style, and size 15
         doublebuffer.drawString("By Darren Cole", 130, 270); //adds words in pink as string and specifies coardinates
         doublebuffer.drawString("Last Modified: 03/04/03", 110, 290); //adds words in pink as string and specifies coardinates
         doublebuffer.drawLine(90, 60, 130, 77); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(210, 60, 250, 77); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 60, 210, 60); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 90, 130, 107); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 60, 90, 90); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.setColor (Color.darkGray); //sets colour to dark grey
         doublebuffer.fillRect(129, 62, 83, 16);
         g.drawImage(buffer,0,0,this);
         public void actionPerformed(ActionEvent e) //tells program that there is an action event specified in the code below
         repaint(); //keeps repainting the digital clock graphics as the time changes i.e. keeps looping the code over
    (END OF CODE)
    What am I doing wrong here? Also I've tried to implement the date as well using a GregorianCalendar. How would I actually make the date appear on the page?
    Thanks,
    Darren

    Most of that doesn't matter now because I've now put in a simplercode for the date but it still doesn't display. But now I get 10 errors. The new code is:
    (START OF CODE)
    import java.awt.*; //puts in abstract windows toolkit to get output on screen
         import java.util.*;
         import java.applet.Applet;
         import java.awt.event.*;
         //<applet code="DigitalClock.class" width=400 height=400></applet> //displays applet without needing to create HTML file
         public class DigitalClock extends Applet implements ActionListener, Runnable //listen for action events
         Graphics doublebuffer;
         private javax.swing.Timer timer; //implements timer
         public void init() {
    timer = new javax.swing.Timer(1000, this);
    timer.setInitialDelay(0);
    timer.start();
         doublebuffer = buffer.getGraphics();
         public void paint(Graphics g) //states that the code below will paint objects onto the applet
         doublebuffer.setColor (Color.white); //sets colour to white
         doublebuffer.drawRect(130, 78, 120, 30); //rectangle shape surrounding digital clock
         doublebuffer.setColor (Color.darkGray); //sets colour to grey
         doublebuffer.fillRect(132, 80, 117, 27); //fills rectangle from code 2 lines up with colour grey
         setBackground(Color.black); //specifies background colour as black
         Calendar date = new GregorianCalendar();
         DateFormat df=DateFormat.getDateInstance(DateFormat.LONG);
         String date = df.format(new Date());
         GregorianCalendar cal = new GregorianCalendar(); //tells program to implement the a new Gregorian Calemder in order to display a date or time
         doublebuffer.setFont(new Font("Arial", Font.BOLD,20)); //sets font to arial, bold style, and size 20
         doublebuffer.setColor (Color.white); //sets colour to white
    doublebuffer.drawString(cal.get(Calendar.HOUR_OF_DAY) + " : " + //examines windows clock to get current hour
    cal.get(Calendar.MINUTE) + " : " + //examines windows clock to get current minute
    cal.get(Calendar.SECOND), 140, 100); //examines windows clock to get current second
         doublebuffer.setFont(new Font("Arial", Font.BOLD,15)); //sets the font to arial, bold style, and size 15
         doublebuffer.drawString("By Darren Cole", 130, 270); //adds words in pink as string and specifies coardinates
         doublebuffer.drawString("Last Modified: 03/04/03", 110, 290); //adds words in pink as string and specifies coardinates
         doublebuffer.drawLine(90, 60, 130, 77); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(210, 60, 250, 77); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 60, 210, 60); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 90, 130, 107); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.drawLine(90, 60, 90, 90); //specifies coardinates for lines that give 3D effect to Digital Clock
         doublebuffer.setColor (Color.darkGray); //sets colour to dark grey
         doublebuffer.fillRect(129, 62, 83, 16);
         g.drawImage(buffer,0,0,this);
         public void actionPerformed(ActionEvent e) //tells program that there is an action event specified in the code below
         repaint(); //keeps repainting the digital clock graphics as the time changes i.e. keeps looping the code over
    (END OF CODE)
    The errors are:
    ---------- Javac ----------
    DigitalClock.java:63: 'class' or 'interface' expected
         public void actionPerformed(ActionEvent e) //tells program that there is an action event specified in the code below
    ^
    DigitalClock.java:70: 'class' or 'interface' expected
    ^
    DigitalClock.java:70: 'class' or 'interface' expected
    ^
    DigitalClock.java:8: DigitalClock should be declared abstract; it does not define run() in DigitalClock
         public class DigitalClock extends Applet implements ActionListener, Runnable //listen for action events
    ^
    DigitalClock.java:21: cannot resolve symbol
    symbol : variable buffer
    location: class DigitalClock
         doublebuffer = buffer.getGraphics();
    ^
    DigitalClock.java:37: cannot resolve symbol
    symbol : class DateFormat
    location: class DigitalClock
         DateFormat df=DateFormat.getDateInstance(DateFormat.LONG);
    ^
    DigitalClock.java:37: cannot resolve symbol
    symbol : variable DateFormat
    location: class DigitalClock
         DateFormat df=DateFormat.getDateInstance(DateFormat.LONG);
    ^
    DigitalClock.java:37: cannot resolve symbol
    symbol : variable DateFormat
    location: class DigitalClock
         DateFormat df=DateFormat.getDateInstance(DateFormat.LONG);
    ^
    DigitalClock.java:38: date is already defined in paint(java.awt.Graphics)
         String date = df.format(new Date());
    ^
    DigitalClock.java:58: cannot resolve symbol
    symbol : variable buffer
    location: class DigitalClock
         g.drawImage(buffer,0,0,this);
    ^
    10 errors
    Normal Termination
    Output completed (2 sec consumed).
    Thanks,
    Darren

  • Double buffer for different components.

    Currently I'm working on a project where I have a JPanel inside of a JFrame. The panel takes up a portion of the frame and on other side I have a JButton and two JTextfields. My double buffer method works fine for the JPanel but every time it's repainted the other components in my JFrame look like they need to be buffered. What would be the best way to fix this? I think I just need to re-add the other components whenever the Panel is repainted but I run into a lot of problems if that's the case.

    We can't see your code so we'll take your word for it. But if I use Swing components they typically don't 'need buffering' by which I assume you mean that they flicker? So the problem is when you combine your code with Swing so you'll have to debug that yourself or show some code (preferrably as SSCCE).

  • Need to output 8 channels using double buffer

    Hi,
    I need to ouput 8 channels to the DAQ card.
    I am getting an array 8 bytes of data every 10 milliseconds.
    Each byte corresponds to a channel.
    I am using your WFMDoubleBuffer.c code.
    The changes I have made are :
    1. Changed the buffer from 32K to 16 bytes. I am assuming 8 bytes with double buffer = 16 bytes
    2. I'm not sure about updateRate, so I set it to 1.0
    Result : I get an error from WFM_Group_Control(). It says "The operation could not complete within the time limit", error = -10800
    I have attached the file for your reference.
    Please help me.
    Thanking you in anticipation
    Chandra
    Attachments:
    WFMdoubleBuf.C ‏8 KB

    Chandra,
    The timeout error here is slightly misleading. The reason this is happening is caused by a few things. By default, the card to setup to transfer data when the onboard FIFO is full, and so your half buffer must be the same size or large than your FIFO unless you have regeneration turned on. Regeneration will cause your buffer to be copied as many times as possible into the FIFO until it is full. Your 6713 has an AO FIFO size of 16,384. So your buffer size must be twice this, so that your half buffer is >= 16384. Where is your data coming from at these 10 ms intervals, from a program or another device? This could affect what method would be the best solution.
    If you want to keep working on this, let�s stick to one channel, I sent you an email, did you get
    it?
    Kevin R
    Applications Engineer
    National Instruments

  • Enabling Double-buffer in JPanel

    Does anyone know how i would enable the double-buffering that JPanel supports. I have heard that it supports that and you have to enable it. If anyone could help i would really appreciate it thanks.
    mdawg

    From the JDK1.2.2 API:
    Constructor Summary
    JPanel()
    Create a new JPanel with a double buffer and a flow layout
    JPanel(boolean isDoubleBuffered)
    Create a new JPanel with FlowLayout and the specified buffering strategy.
    JPanel(LayoutManager layout)
    Create a new buffered JPanel with the specified layout manager
    JPanel(LayoutManager layout, boolean isDoubleBuffered)
    Creates a new JPanel with the specified layout manager and buffering strategy.
    It would appear that double buffering is the default.

  • Double Buffer program is slowing down, help.

    Hello, I have a small Dancing Lines program like an old Windows screensaver program and it appears to slow down after about 30 seconds to a minute. I "clear" my buffer by copying a screen sized black symbol to the buffer. If anyone has any ideas about how to make this more efficient and most importantly stop the slow down, please let me know, thanks.
    // Variables
    var x0:int;
    var y0:int;
    var x1:int;
    var y1:int;
    var x2:int;
    var y2:int;
    var x3:int;
    var y3:int;
    var dx0:int;
    var dy0:int;
    var dx1:int;
    var dy1:int;
    var dx2:int;
    var dy2:int;
    var dx3:int;
    var dy3:int;
    var counter:int = 0;
    var clearBuffer:Buffer = new Buffer();
    var drawing:Shape = new Shape();
    var color1:uint = uint(0xFFFFFF * Math.random());
    // Initialize Line Values
    x0 = int(Math.random() * 320);
    x1 = int(Math.random() * 320);
    y0 = int(Math.random() * 200);
    y1 = int(Math.random() * 200);
    x2 = x0;
    x3 = x1;
    y2 = y0;
    y3 = y1;
    // Initializing Line Velocities
    dx0 = int(Math.random() * 5);
    dx1 = int(Math.random() * 5);
    dy0 = int(Math.random() * 5);
    dy1 = int(Math.random() * 5);
    dx2 = dx0;
    dx3 = dx1;
    dy2 = dy0;
    dy3 = dy1;
    // Double Buffer Setup
    var bitmap:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);                          
    var buffer:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);
    var image:Bitmap = new Bitmap(bitmap);
    addChild(image);
    // Listeners
    addEventListener(Event.ENTER_FRAME,onEnterFrame);
    function onEnterFrame(event:Event):void {
         // Clear The Sreen
         buffer.draw(clearBuffer);
         // Logic
         drawing.graphics.lineStyle(1, color1);
         drawing.graphics.moveTo(x0,y0);
         drawing.graphics.lineTo(x1,y1);
         if ((x0 += dx0) >= 315 || x0 < 5)
              dx0 *= -1;
         if ((y0 += dy0) >= 195 || y0 < 5)
              dy0 *= -1;
         if ((x1 += dx1) >= 315 || x1 < 5)
              dx1 *= -1;
         if ((y1 += dy1) >= 195 || y1 < 5)
              dy1 *= -1;
         if (++counter > 50) {
              drawing.graphics.lineStyle(1, 0x000000);
              drawing.graphics.moveTo(x2,y2);
              drawing.graphics.lineTo(x3,y3);
              if ((x2 += dx2) >= 315 || x2 < 5)
                   dx2 *= -1;
              if ((y2 += dy2) >= 195 || y2 < 5)
                   dy2 *= -1;
              if ((x3 += dx3) >= 315 || x3 < 5)
                   dx3 *= -1;
              if ((y3 += dy3) >= 195 || y3 < 5)
                   dy3 *= -1;
         if (counter > 250)
              counter = 51;
         // Draw The Screen
         buffer.draw(drawing, drawing.transform.matrix);
         bitmap.draw(buffer);
    P.S. - Is there a way I can post my code in a smaller box with a scrollbar?

    Here is a fixed version:
    // Variables
    var x0:int;
    var y0:int;
    var x1:int;
    var y1:int;
    var x2:int;
    var y2:int;
    var x3:int;
    var y3:int;
    var dx0:int;
    var dy0:int;
    var dx1:int;
    var dy1:int;
    var dx2:int;
    var dy2:int;
    var dx3:int;
    var dy3:int;
    var counter:int = 0;
    var drawing:Shape = new Shape();
    var color1:uint = uint(0xFFFFFF * Math.random());
    // Initialize Line Values
    x0 = int(Math.random() * 320);
    x1 = int(Math.random() * 320);
    y0 = int(Math.random() * 200);
    y1 = int(Math.random() * 200);
    x2 = x0;
    x3 = x1;
    y2 = y0;
    y3 = y1;
    // Initializing Line Velocities
    dx0 = int(Math.random() * 5);
    dx1 = int(Math.random() * 5);
    dy0 = int(Math.random() * 5);
    dy1 = int(Math.random() * 5);
    dx2 = dx0;
    dx3 = dx1;
    dy2 = dy0;
    dy3 = dy1;
    // Double Buffer Setup
    var bitmap:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);                         
    var buffer:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);
    var image:Bitmap = new Bitmap(bitmap);
    addChild(image);
    // Listeners
    addEventListener(Event.ENTER_FRAME,onEnterFrame);
    function onEnterFrame(event:Event):void {
         // Logic
         drawing.graphics.lineStyle(1, color1);
         drawing.graphics.moveTo(x0,y0);
         drawing.graphics.lineTo(x1,y1);
         if ((x0 += dx0) >= 315 || x0 < 5)
              dx0 *= -1;
         if ((y0 += dy0) >= 195 || y0 < 5)
              dy0 *= -1;
         if ((x1 += dx1) >= 315 || x1 < 5)
              dx1 *= -1;
         if ((y1 += dy1) >= 195 || y1 < 5)
              dy1 *= -1;
         if (++counter > 50) {
              drawing.graphics.lineStyle(1, 0x000000);
              drawing.graphics.moveTo(x2,y2);
              drawing.graphics.lineTo(x3,y3);
              if ((x2 += dx2) >= 315 || x2 < 5)
                   dx2 *= -1;
              if ((y2 += dy2) >= 195 || y2 < 5)
                   dy2 *= -1;
              if ((x3 += dx3) >= 315 || x3 < 5)
                   dx3 *= -1;
              if ((y3 += dy3) >= 195 || y3 < 5)
                   dy3 *= -1;
         // Draw The Screen
         buffer.draw(drawing, drawing.transform.matrix);
         bitmap.draw(buffer);
         // clear drawing canvas
         drawing.graphics.clear();
    Basically you have to use the graphics.clear() function to erase any clip where you are using the drawing API. Drawing lots of vectors can be very costly performance-wise so you always want to clear your graphics when you are finished. Drawing over the vectors with a rectangle has no effect except to increase the load even more. However when dealing with bitmap objects you can safely draw as much as you want for as long as you wish with no performance hit. Thats why what you were trying to do with that "clearBuffer" was not doing anything. Also, setting the counter to 51 when it got to 250 was doing nothing whatsoever. Not sure what that was for. The code should work fine now.

  • Swings auto double buffer

    Swing has double buffering by default, but i still see flicker.
    whay does it flicker it double buffering is turned on.

    Well ive eliminated it now by using....
    <code>
    public void paint(Graphics g){
         update(g);
    public void update(Graphics g){
         // Draws the buffered image to the screen.
         g.drawImage(imageOffScreen, xPos, 0, this);
    </code>
    ..... and doing my drawing in another Graphicsoject.

  • How to double-buffer a JWindow?

    Hi,
    I made a resizable JWindow, but whenever I resize, J-components within the window flicker. (First setSize(), then validate() to redraw for correct sizes). I know JWindow is not double buffered, I want to override the paint() method to implement double buffering -- anyone knows how to do that? (...besides copying from JComponent.java)

    I think double buffering available in Swing with out you doing anything. Just add the following line to your window initialization.
    ((JPanel)window.getContentPane()).setDoubleBuffered(true);If this doesn't work, and I think it should. Then use the code below.
    This is code copied from http://java.sun.com/j2se/1.3/docs/guide/awt/designspec/lightweights.html
    The following is a Panel, but you can apply the same logic to JWindow.
    public class DoubleBufferPanel extends Panel {   
      Image offscreen;
       * null out the offscreen buffer as part of invalidation
      public void invalidate() {
          super.invalidate();
          offscreen = null;
       * override update to *not* erase the background before painting
      public void update(Graphics g) {
          paint(g);
       * paint children into an offscreen buffer, then blast entire image
       * at once.
      public void paint(Graphics g) {
          if(offscreen == null) {
             offscreen = createImage(getSize().width, getSize().height);
          Graphics og = offscreen.getGraphics();
          og.setClip(0,0,getSize().width, getSize().height);
          super.paint(og);
          g.drawImage(offscreen, 0, 0, null);
          og.dispose();

  • Conky won't use double buffer anymore?

    i posted the other day having issues setting up dual monitors, not that i got any help, but figured i'd mention. anyway, since i've had the dual monitors setup, conky won't run using double buffering for some reason. its in my conky config, and DBE is being loaded in my xorg.conf. so its bugging me now. wondering is anyone has a clue here. my system is fully up to date as of right now, and running an nvidia card, so nvidia driver on a 7900GS video card, might be an 8800, i forget which card is in which box at the moment
    here's my conky config
    alignment top_right
    background yes
    border_width 1
    cpu_avg_samples 2
    default_color white
    default_outline_color black
    default_shade_color black
    draw_borders no
    draw_graph_borders yes
    #draw_outline yes
    draw_shades yes
    use_xft yes
    xftfont DejaVu Sans Mono:size=10
    gap_x 5
    gap_y 5
    minimum_size 5 5
    net_avg_samples 2
    #no_buffers yes
    double_buffer yes
    out_to_console no
    out_to_stderr no
    own_window yes
    own_window_transparent yes
    own_window_class Conky
    own_window_type desktop
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_page
    stippled_borders 0
    update_interval 1.0
    uppercase no
    use_spacer none
    show_graph_scale no
    show_graph_range no
    TEXT
    $nodename - $sysname $kernel on $machine
    Uptime:$color $uptime
    $hr
    CPU > ${freq}MHz ${hr 1}$color
    CPU Usage:$color $cpu% ${cpubar 4}
    ${cpugraph 15,280 ffffff 00A2FF}
    MEMORY $memmax ${hr 1}
    RAM : $mem / $memperc%${alignr}${membar 6,120}
    I/O : ${diskio}${alignr}${diskiograph 6,120}
    DISK > /dev/ ${hr 1}$color
    Root ( sda3 ): ${fs_free /} ${fs_bar 6 /}
    Home ( sda4 ): ${fs_free /home} ${fs_bar 6 /home}
    Movies ( sdb1 ): ${fs_free /home/movies} ${fs_bar 6 /home/movies}
    Windows ( sdc1 ): ${fs_free /mnt/sdc1} ${fs_bar 6 /mnt/sdc1}
    NETWORK > ${addr eth0} ${hr 1}$color
    ${downspeedgraph eth0 15,135 ffffff 00A2FF} ${upspeedgraph eth0 15,135 ffffff 00A2FF}
    Down / Up Speed: ${downspeed eth0} k/s / ${upspeed eth0} k/s
    Down / Up Bytes: ${totaldown eth0} / ${totalup eth0}
    Inbound / Outbound / Total: ${tcp_portmon 1 32767 count} / ${tcp_portmon 32768 61000 count} / ${tcp_portmon 1 65535 count}
    PROCESSES > ${processes} / ${running_processes} ${hr 1}$color
    NAME PID CPU% MEM%
    ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
    ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
    ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
    ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
    ${top name 5} ${top pid 5} ${top cpu 5} ${top mem 5}
    ${exec feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-appletsrc | tail --lines=1 | sed 's/wallpaper=//'`"}
    here's my xorg.conf as well if it helps. if there is anything someone can suggest adding or removing from it, especially to tweak video performance, i'm wide open for suggestions while im here
    Section "ServerLayout"
    Identifier "Xorg Configured"
    Screen 0 "Screen0" LeftOf "Screen1"
    Screen 1 "Screen1" 1600 0
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "PS/2 Mouse" "CorePointer"
    EndSection
    Section "Files"
    ModulePath "/usr/lib/xorg/modules"
    FontPath "/usr/share/fonts/misc:unscaled"
    FontPath "/usr/share/fonts/misc"
    FontPath "/usr/share/fonts/75dpi:unscaled"
    FontPath "/usr/share/fonts/75dpi"
    FontPath "/usr/share/fonts/100dpi:unscaled"
    FontPath "/usr/share/fonts/100dpi"
    FontPath "/usr/share/fonts/PEX"
    FontPath "/usr/share/fonts/cyrillic"
    FontPath "/usr/share/fonts/Type1"
    FontPath "/usr/share/fonts/ttf/western"
    FontPath "/usr/share/fonts/ttf/decoratives"
    FontPath "/usr/share/fonts/truetype"
    FontPath "/usr/share/fonts/truetype/openoffice"
    FontPath "/usr/share/fonts/truetype/ttf-bitstream-vera"
    FontPath "/usr/share/fonts/latex-ttf-fonts"
    FontPath "/usr/share/fonts/defoma/CID"
    FontPath "/usr/share/fonts/defoma/TrueType"
    EndSection
    Section "Module"
    Load "ddc" # ddc probing of monitor
    Load "dbe"
    Load "extmod"
    Load "glx"
    Load "bitmap" # bitmap-fonts
    EndSection
    Section "ServerFlags"
    Option "AllowMouseOpenFail" "true"
    Option "Xinerama" "1"
    EndSection
    Section "InputDevice"
    Identifier "Keyboard0"
    Driver "keyboard"
    Option "CoreKeyboard"
    Option "XkbRules" "xorg"
    Option "XkbModel" "pc105"
    Option "XkbLayout" "us"
    Option "XkbVariant" ""
    EndSection
    Section "InputDevice"
    Identifier "Serial Mouse"
    Driver "mouse"
    Option "Protocol" "Microsoft"
    Option "Device" "/dev/ttyS0"
    Option "Emulate3Buttons" "true"
    Option "Emulate3Timeout" "70"
    Option "SendCoreEvents" "true"
    EndSection
    Section "InputDevice"
    Identifier "PS/2 Mouse"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "ZAxisMapping" "4 5"
    Option "Device" "/dev/psaux"
    Option "Emulate3Buttons" "true"
    Option "Emulate3Timeout" "70"
    Option "SendCoreEvents" "true"
    EndSection
    Section "InputDevice"
    Identifier "USB Mouse"
    Driver "mouse"
    Option "Device" "/dev/input/mice"
    Option "SendCoreEvents" "true"
    Option "Protocol" "IMPS/2"
    Option "ZAxisMapping" "4 5"
    Option "Buttons" "5"
    EndSection
    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Unknown"
    ModelName "CRT-0"
    HorizSync 30.0 - 121.0
    VertRefresh 48.0 - 160.0
    ModeLine "1600x1200" 175.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync
    Option "DPMS" "true"
    EndSection
    Section "Monitor"
    Identifier "Monitor1"
    VendorName "Unknown"
    ModelName "SUN GDM-5410"
    HorizSync 30.0 - 121.0
    VertRefresh 48.0 - 160.0
    EndSection
    Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BoardName "GeForce 7900 GS"
    BusID "PCI:2:0:0"
    Screen 0
    EndSection
    Section "Device"
    Identifier "Device1"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BoardName "GeForce 7900 GS"
    BusID "PCI:2:0:0"
    Screen 1
    EndSection
    Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "TwinView" "0"
    Option "TwinViewXineramaInfoOrder" "CRT-0"
    Option "metamodes" "CRT-0: 1600x1200_75 +0+0"
    SubSection "Display"
    Depth 24
    EndSubSection
    EndSection
    Section "Screen"
    Identifier "Screen1"
    Device "Device1"
    Monitor "Monitor1"
    DefaultDepth 24
    Option "TwinViewXineramaInfoOrder" "CRT-0"
    Option "TwinView" "0"
    Option "metamodes" "CRT-1: 1600x1200 +0+0"
    SubSection "Display"
    Depth 24
    EndSubSection
    EndSection

    Hi @Arboria9 ,
    I see that you are experiencing issues printing two-sided from Yosemite. I would like to help you resolve this issue.
    You have pretty much have done all the steps that I would have provided.
    Are you still able to print two-sided from the Windows computer?
    Are you missing the option to select two-sided printing in the print driver?
    Check the driver name that is installed for the printer. Make sure it shows just the printer's name.
    Click the Apple menu and then click System Preferences. Click Printers & Scanners, highlight the printer name on the left side and on the right side of the screen it should show the printer's name. (Officejet 6500)
    If the full printer name isn't listed correctly, delete it and add the printer name back in from the list. Click the - sign to delete the driver and then click the + sign to add the driver, might have to click the drop down to select the printer's name to add it in.
    How was the printer name listed?
    If you need further assistance, just let me know.
    Have a great day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • To double buffer or not double buffer..that is the question

    i am not very familiar with double buffering but am reading examples
    of it now. Im not doing animaiton and i dont think im doing alot of
    drawing to the screen but im arookie so its hard to tell. Can you tell
    me if i should implement double buffering by looking at my code. Im
    wondering cuz my webpage is a mess.(http://ktowndrivewaysealing.tripod.com).
    i have trailing components and flickering and i dont know how to fix it.
    thanx
    trin
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    public class MyProg extends Applet implements ActionListener
         Button btnOne = new Button("Home");
         Button btnTwo = new Button("Asphalt Sealing");
         Button btnThree = new Button("Crack Repairs");
         Button btnFour = new Button("Pressure Washing");
         Button btnFive = new Button("Free Estimates");
         Button btnSix = new Button("Contact Us");
         Font font1= new Font ( "TimesNewRoman",Font.BOLD,12);     
         Font font2=new Font("TimesNewRoman", Font.BOLD, 35);
         Font font3=new Font("TimesNewRoman", Font.BOLD, 25);
         Font font4=new Font("TimesNewRoman",Font.BOLD,20);
         Font font5=new Font("Dialog", Font.BOLD+Font.ITALIC, 16);
         Label title1=new Label("KINGSTON", Label.CENTER);
         Label title2 = new Label("Driveway Sealing", Label.CENTER);
         Label title3=new Label("613-531-3369", Label.CENTER);
         Label caption1=new Label("Your driveway is the first impression your home makes...", Label.CENTER);
         Label caption2=new Label("Make it a Good one.", Label.CENTER);
         Image drivewaypic1;
         Image drivewaypic2;
         URL homeUrl;
         URL asphaltUrl;
         URL crackUrl;
         URL pressureUrl;
         URL freeUrl;
         URL contactUrl;
         public void init()
              setLayout(null);
               try
                   homeUrl = new URL(getCodeBase(),"Home.html");
                   asphaltUrl=new URL(getCodeBase(),"AsphaltHtml.html");
                   crackUrl= new URL(getCodeBase(),"CrackHtml.html");
                   pressureUrl=new URL(getCodeBase(),"PressureHtml.html");
                   freeUrl= new URL(getCodeBase(),"FreeHtml.html");
                   contactUrl= new URL(getCodeBase(),"ContactUsHtml.html");
              catch (MalformedURLException e)
                    return;//maybe i should leave blank..will test later
              drivewaypic1=getImage(getCodeBase(),"drivewaypic1.jpg");
              drivewaypic2=getImage(getCodeBase(),"drivewaypic2.jpg");
              add(btnOne);
              add(btnTwo);
              add(btnThree);
              add(btnFour);
              add(btnFive);
              add(btnSix);
              add(title1);
              add(title2);
              add(title3);
              add(caption1);
              add(caption2);
              btnOne.setFont(font1);
              btnOne.setBounds(15,159,120,40);
              btnOne.setBackground(Color.black);
              btnOne.setForeground(Color.white);
              btnTwo.setFont(font1);
              btnTwo.setBounds(15,199,120,40);
              btnTwo.setBackground(Color.black);
              btnTwo.setForeground(Color.white);
              btnThree.setFont(font1);
              btnThree.setBounds(15,239,120,40);
              btnThree.setBackground(Color.black);
              btnThree.setForeground(Color.white);
              btnFour.setFont(font1);
              btnFour.setBounds(15,279,120,40);
              btnFour.setBackground(Color.black);
              btnFour.setForeground(Color.white);
              btnFive.setFont(font1);
              btnFive.setBounds(15,319,120,40);
              btnFive.setBackground(Color.black);
              btnFive.setForeground(Color.white);
              btnSix.setFont(font1);
              btnSix.setBounds(15,359,120,40);
              btnSix.setBackground(Color.black);
              btnSix.setForeground(Color.white);
              title1.setBounds(5,5,585,33);
              title1.setBackground(Color.lightGray);
              title1.setForeground(Color.black);
              title1.setFont(font3);
              title2.setBounds(5,39,590,36);
              title2.setBackground(Color.black);
              title2.setForeground(Color.white);
              title2.setFont(font2);
              title3.setBounds(5,75,590,30);
              title3.setBackground(Color.lightGray);
              title3.setForeground(Color.black);
              title3.setFont(font4);
              caption1.setBounds(163,113,450,23);
              caption1.setFont(font5);
              caption1.setBackground(Color.lightGray);
              caption1.setForeground(Color.blue);
              caption2.setBounds(163,134,446,23);
              caption2.setFont(font5);
              caption2.setBackground(Color.lightGray);
              caption2.setForeground(Color.blue);
              btnOne.addActionListener(this);
              btnTwo.addActionListener(this);
              btnThree.addActionListener(this);
              btnFour.addActionListener(this);
              btnFive.addActionListener(this);
              btnSix.addActionListener(this);
              btnOne.setActionCommand("Home");
              btnTwo.setActionCommand("Asphalt Sealing");
              btnThree.setActionCommand("Crack Repairs");
              btnFour.setActionCommand("Pressure Washing");
              btnFive.setActionCommand("Free Estimates");
              btnSix.setActionCommand("Contact Us");
         public void actionPerformed (ActionEvent e)
              String s=e.getActionCommand();
              if (s.equals("Home"))
                   getAppletContext().showDocument(homeUrl);
              if (s.equals("Asphalt Sealing"))
                   getAppletContext().showDocument(asphaltUrl);
              if (s.equals("Crack Repairs"))
                   getAppletContext().showDocument(crackUrl);
              if (s.equals("Pressure Washing"))
                   getAppletContext().showDocument(pressureUrl);
              if (s.equals("Free Estimates"))
                   getAppletContext().showDocument(freeUrl);
              if (s.equals("Contact Us"))
                   getAppletContext().showDocument(contactUrl);
         public void paint(Graphics g)
              super.paint(g);
              g.setColor(Color.lightGray);
              g.fillRect(1,1,600,600);
              //g.fillRect(1,1,147,650);
              g.setColor(Color.black);
              g.drawRoundRect(1,1,595,105,10,10);     
              g.drawRoundRect(2,2,593,103,10,10);     
              g.drawRoundRect(3,3,591,101,10,10);     
              g.drawRoundRect(4,4,589,99,10,10);
              g.drawImage(drivewaypic1,170,159,375,225,this);     
              g.drawImage(drivewaypic2,170,386,375,225,this);
              g.drawRoundRect(1,110,150,495,10,10);
              g.drawRoundRect(2,111,148,493,10,10);
              g.drawRoundRect(3,112,146,491,10,10);
              g.drawRoundRect(4,113,144,489,10,10);
         

    It seems you aren't using any animation in this applet, so you won't have to use double buffering... :)

  • Has anyone ever successful​ly done a cont double buffer acq from multiple SCXI channels AND a spare AI of the MIO that controls the SCXI chassis at the same time?

    I am trying do a sanity check before I order some hardware.
    What I want to do is acquire from multiple channels in a SCXI chasis and as part of the same acquisition, also read from one of the "un-used" AI channels of the MIO card.
    My concern is this:
    All of the channels of the SCXI chassis get multiplexed down into a single channel of the MIO card that controls the SCXI chassis. This means that channel 0 has to do multiple A/D conversions to get a reading from all of the configured SCXI channels.
    Meanwhile, the other AI channel of the MIO only has to do one to get it's reading. It seems that the on-boar
    d clock of the MIO would have to run at two rates to be able to read all of my SCXI channels AND the other AI channel.
    What I want to do:
    I want to just configure a vitual channel for all of my SCXI channels AND one more for one "odd-ball" signal that is incompatable with all of the SCXI modules.
    Then I just want to list all of my virtual channels when I configure and start my continuous double buffered acquisition.
    I have successfully done all SCXI channels before, but I have never tried to use one of the un-used AI on the MIO at the same time. I have used the spare DIO lines previously, but that will not work in this app.
    So...
    If you have done this and it worked, I would greatly appreciate hearing about any special techniques that were used, etc.
    Thank you for reading this question,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

    Jeremy answered here
    http://exchange.ni.com/servlet/ProcessRequest?RHIV​EID=101&RPAGEID=135&HOID=50650000000800000007C4000​0&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Has anyone ever successfully done a cont double buffer acq from multiple SCXI channels AND a spare AI of the MIO that controls the SCXI chassis at the same time?

    I am trying do a sanity check before I order some hardware.
    What I want to do is acquire from multiple channels in a SCXI chasis and as part of the same acquisition, also read from one of the "un-used" AI channels of the MIO card.
    My concern is this:
    All of the channels of the SCXI chassis get multiplexed down into a single channel of the MIO card that controls the SCXI chassis. This means that channel 0 has to do multiple A/D conversions to get a reading from all of the configured SCXI channels.
    Meanwhile, the other AI channel of the MIO only has to do one to get it's reading. It seems that the on-boar
    d clock of the MIO would have to run at two rates to be able to read all of my SCXI channels AND the other AI channel.
    What I want to do:
    I want to just configure a vitual channel for all of my SCXI channels AND one more for one "odd-ball" signal that is incompatable with all of the SCXI modules.
    Then I just want to list all of my virtual channels when I configure and start my continuous double buffered acquisition.
    I have successfully done all SCXI channels before, but I have never tried to use one of the un-used AI on the MIO at the same time. I have used the spare DIO lines previously, but that will not work in this app.
    So...
    If you have done this and it worked, I would greatly appreciate hearing about any special techniques that were used, etc.
    Thank you for reading this question,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

    Jeremy answered here
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000007C40000&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How do i double buffer this code (URGENT)

    i make an image move when user presses the arrow buttons but the moving image flickers how do i prevent that
    the code:
    import java.awt.*;
    import java.io.*;
    public class KenshinGame extends Frame{
    MoveImages mi = new MoveImages();
    int x = 355;
    int y = 10;
    int spaceCount = 0;
    public KenshinGame () {
         add ("Center", mi);
    public boolean handleEvent (Event evt){
         if (evt.id == Event.WINDOW_DESTROY){
         System.exit(0);
         return super.handleEvent(evt);
    public boolean keyDown(Event evt, int key){
    if (key == Event.LEFT) {
         //System.out.println (x);
         if (y > 125 && y <170 && x > 65){
         x = x - 10;
         mi.move(x, y);
         else if (y < 650&& y > 620 && x > 110){
         x = x - 10;
         mi.move(x, y);
    else if (key == Event.RIGHT) {
         //System.out.println (x);
         if (y > 125 && y <170 && x < 675){
         x = x + 10;
         mi.move(x, y);
         else if (y < 650&& y > 620 && x < 640){
         x = x + 10;
         mi.move(x, y);
    else if (key == Event.UP) {
         //System.out.println (y);
         if (y > 10 && x == 355){
         y = y - 10;
         mi.move(x, y);
         else if (y > 120 && x > 320 && x < 390){
         y = y - 10;
         mi.move(x, y);
         else if (x < 130 && x > 110 && y > 120 && y < 170){
         y = y - 10;
         mi.move(x, y);
         else if (x > 475 && x < 515 && y > 110 && y < 170){
         y = y - 10;
         mi.move(x, y);
         else if (x > 625 && x < 655 && y > 110 && y < 170){
         y = y - 10;
         mi.move(x, y);
         else if (x < 130 && x > 110 && y > 605 && y < 640){
         y = y - 10;
         mi.move(x, y);
    else if (key == Event.DOWN) {
         if (x > 320 && x < 390 && y < 670){
         y = y + 10;
         mi.move(x, y);
         else if (x < 130 && x > 110 && y > 100 && y < 170){
         y = y + 10;
         mi.move(x, y);
         else if (x > 475 && x < 515 && y > 90 && y < 170){
         y = y + 10;
         mi.move(x, y);
         else if (x > 625 && x < 655 && y > 90 && y < 170){
         y = y + 10;
         mi.move(x, y);
         else if (x < 130 && x > 110 && y > 595 && y < 640){
         y = y + 10;
         mi.move(x, y);
         else if (y > 660){
         x = 615;
         y = 390;
         mi.move (x, y);
    return true;
    public static void main(String args[]) {
         Frame f = new KenshinGame();
         f.resize (760, 740);
         f.show();
         f.setTitle ("Gmae: Level 1");
    class MoveImages extends Canvas {
    int x = 355;
    int y = 10;
    int w = 10;
    int h = 20;
    String mapLoc = new String ("c:\\My Documents\\My Pictures\\liotto.gif");
    String maincLoc = new String ("c:\\My Documents\\My Pictures\\rstand.gif");
    Image map = Toolkit.getDefaultToolkit().getImage(mapLoc);
    Image mainc = Toolkit.getDefaultToolkit().getImage (maincLoc);
    public void paint (Graphics g){
         MediaTracker tracker = new MediaTracker(this);
         tracker.addImage(map, 0);
         g.drawImage (map, 0, 0, this);
         try {     
         tracker.waitForAll();
         catch (InterruptedException e) {
         g.drawImage (mainc, x, y, this);
    public void move(int xCo, int yCo){
         x = xCo;
         y = yCo;
         repaint();
    public void update (Graphics g){
         paint (g);
    }

    i havent changed the main class but i did change the canvas because i have figured out how to use double buffering any suggestions how i can fix this instead:
    class MoveImages extends Canvas {
    int x = 355;
    int y = 10;
    String di = "stand";
    String mapLoc = new String ("c:\\My Documents\\My Pictures\\liotto.gif");
    Image map = Toolkit.getDefaultToolkit().getImage(mapLoc);
    Image stand = Toolkit.getDefaultToolkit().getImage("c:\\My Documents\\My Pictures\\rstand.gif");
    Image walka = Toolkit.getDefaultToolkit().getImage("c:\\My Documents\\My Pictures\\rwalka.gif");
    Image walkt = Toolkit.getDefaultToolkit().getImage("c:\\My Documents\\My Pictures\\rwalkt.gif");
    Image walkl = Toolkit.getDefaultToolkit().getImage("c:\\My Documents\\My Pictures\\rwalkl.gif");
    Image walkr = Toolkit.getDefaultToolkit().getImage("c:\\My Documents\\My Pictures\\rwalkr.gif");
    int w = 760;
    int h = 740;
    Image offscreen ;
    Graphics og;
    public MoveImages (){
    public void paint (Graphics g){
         g.drawImage (map, 0, 0, this);
         if (di.equals ("stand")){
         g.drawImage (walka, x, y, this);
         g.drawImage (walkt, x, y, this);
         g.drawImage (walkl, x, y, this);
         g.drawImage (walkr, x, y, this);
         g.drawImage (stand, x, y, this);
         else if (di.equals ("walka")){
         g.drawImage (walkt, x, y, this);
         g.drawImage (walkl, x, y, this);
         g.drawImage (walkr, x, y, this);
         g.drawImage (stand, x, y, this);
         g.drawImage (walka, x, y, this);
         else if (di.equals ("walkt")){
         g.drawImage (walkl, x, y, this);
         g.drawImage (walkr, x, y, this);
         g.drawImage (stand, x, y, this);
         g.drawImage (walka, x, y, this);
         g.drawImage (walkt, x, y, this);
         else if (di.equals ("walkl")){
         g.drawImage (walkt, x, y, this);
         g.drawImage (walkr, x, y, this);
         g.drawImage (stand, x, y, this);
         g.drawImage (walka, x, y, this);
         g.drawImage (walkl, x, y, this);
         else if (di.equals ("walkr")){
         g.drawImage (walkt, x, y, this);
         g.drawImage (walkl, x, y, this);
         g.drawImage (stand, x, y, this);
         g.drawImage (walka, x, y, this);
         g.drawImage (walkr, x, y, this);
    public void move(int xCo, int yCo, String direction){
         di = direction;
         x = xCo;
         y = yCo;
         repaint();
    public void addNotify(){
         super.addNotify();
    public void update (Graphics g){
         if (offscreen == null){
         offscreen = createImage (w, h);
    og = offscreen.getGraphics ();
         paint (og);
         g.drawImage (offscreen, 0, 0, this);
    }

Maybe you are looking for