Help with double buffer

I have a series of images that I display on a jLabel using imageIcon that get loaded depending on the mouse position on the label. I would like to preload these images somehow so that there is no wait time for the user when these images are called up. It seems that the doublebuffer object might help with this but I am not sure how....Any help appreciated..
Jacques

Well you can create an array of Image Icons and put you images there ...
ImageIcon[] myImages = new ImageIcon[number_Of_Images]; -MaxxDmg
- ' He who never sleeps...'

Similar Messages

  • Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.

    Before I go into a lengthy explanation of the problem: Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.
    Thanks much.
    Emile

    Choose Force Quit from the Apple menu and close Mail from there.
    (103661)

  • Need help with doubles

    I need help with a double cheeseburger. I want one for lunch but am not hungry enough to eat it all. Who wants half?
    We can split some Walker's crisps, too.

    public class DoubleCheeseburger extends Hamburger
      implements AnnoyanceOfAnimalRightsAdvocates
       boolean bacon;
       public DoubleCheeseburger()
          bacon = false; //explicitly don't want bacon
       public DoubleCheeseburger(boolean bacon)
          this.bacon = bacon;
       public boolean splitIt(int portions)
          boolean cleanSplit = true;
          System.out.println("Splitting the food into wedges of "+(360/portions)+" degrees each.");
          if (bacon = false)
             System.out.println("No need to worry about splitting the bacon slices.");
             cleanSplit = true;
          else
             System.out.println("Someone may not get enough bacon.");
             cleanSplit = false;
          return cleanSplit;
    }

  • Help with doubles and intergers

    I'm new to JAVA programing. So, I'm hoping that someone can help me. Below is part of my code that I'm having a problem with.
    int gold, total
    double percent
    percent = ((gold / total) * 100)
    comes out looking like 0.0
    Is there a way to define (gold / total) as a double in the math statement?
    Thank you for all your help,
    Jennifer

    The problem is integer division always produces an integer, so for example:
    1 / 2 == 0, not 0.5
    but:
    ((double) 1) / 2 == (approximately, allowing for IEEE floating point precision errors) 0.5
    same for 1 / ((double) 2) or using literal constants like 1.0 / 2

  • Need help with double buffering

    Hi!
    I'm trying to write an animated applet the shows the Java Duke waving.
    No problem getting it to work, but the applet is flickering and I sence the need for double buffering.
    I've tried to use "traditional" double buffering techniques without success. Something like this:
    currentDuke = bufferGraphics.getGraphics();
    public void update(Graphics g) {
        bufferGraphics.clearRect(0, 0, this.getWidth(), this.getHeight());
        paint(g);
    public void paint(Graphics g) {
        bufferGraphics.drawImage(nextDuke, 0, 0, this);
        g.drawImage(currentDuke, 0, 0, this);
    }Didn't help...
    Here's my current code:
    import javax.swing.*;
    import java.awt.*;
    * This is a simple animation applet showing Duke waving.
    * @author Andrew
    * @version 1.0 2002-07-04
    public class WavingDuke extends JApplet implements Runnable {
        private Image[] duke;
        private Image currentDuke;
        private Thread wave;
         * Called by the browser or applet viewer to inform this applet that it has
         * been loaded into the system.
        public void init() {
            loadDuke();
            currentDuke = this.createImage(this.getWidth(), this.getHeight());
         * Called by the browser or applet viewer to inform this applet that it
         * should start its execution.
        public void start() {
            if (wave == null) {
                wave = new Thread(this);
                wave.start();
         * Loads all the duke images into a <code>Image</code> array.
        private void loadDuke() {
            duke = new Image[10];
            for (int i = 0; i < 10; i++) {
                duke[i] = this.getImage(this.getCodeBase(), "images/duke"+i+".gif");
         * Method cycles through different images and calls <code>repaint</code>
         * to make an animation. After each call to <code>repaint</code> the thread
         * sleeps for predefined amount of time.
        public void run() {
            while (true) {
                for (int i = 0; i < 10; i++) {
                    currentDuke = duke;
    repaint();
    paus(150);
    * Method makes the current thread to sleep for tha amount of time
    * specified in parameter <code>ms</code>.
    * @param ms The time to wait specified in milliseconds.
    private void paus(int ms) {
    try {
    Thread.sleep(ms);
    } catch (InterruptedException ie) {
    System.err.println(ie.getMessage());
    * Updates this component.
    * @param g The specified context to use for updating.
    public void update(Graphics g) {
    paint(g);
    * Paints this component.
    * @param g The graphics context to use for painting.
    public void paint(Graphics g) {
    g.clearRect(0, 0, this.getWidth(), this.getHeight());
    g.drawImage(currentDuke, 0, 0, this);
    Thanks in advance!
    /Andrew

    I've solved it!
    /Andrew

  • Help with Double.NaN

    This class is supposed to check how many real numbers are being sent to All and depending on that perform further operations with those numbers.
    It works just fine if all four number are present, but if one number is missing (i.e. fourth number in n2 in main), when it goes to All the first condition is ALWAYS true, even though it says if the number is not NaN it just skips it and goes to AllN with four numbers. Am I not using Double.NaN right?
    public class Numbers {
    public double num1 = Double.NaN, num2 = Double.NaN;
    public double num3 = Double.NaN, num4 = Double.NaN;
    public double first = Double.NaN, second = Double.NaN;
    public double third = Double.NaN, fourth = Double.NaN;
    public String snum0;
    // accessor methhods
    public void setNum1 (double value) {
    num1 = value;
    public void setNum2 (double value) {
    num2 = value;
    public void setNum3 (double value) {
    num3 = value;
    public void setNum4 (double value) {
    num4 = value;
    public double getNum1 () {
    return num1;
    public double getNum2 () {
    return num2;
    public double getNum3 () {
    return num3;
    public double getNum4 () {
    return num4;
    public double getFirst () {
    if (first != Double.NaN)
    return first;
    else
    return Double.NaN;
    public double getSecond () {
    if (second != Double.NaN)
    return second;
    else
    return Double.NaN;
    public double getThird () {
    if (third != Double.NaN)
    return third;
    else
    return Double.NaN;
    public double getFourth () {
    if (fourth != Double.NaN)
    return fourth;
    else
    return Double.NaN;
    public void All (Numbers s) {
    if (s.num4 != Double.NaN &&
    s.num3 != Double.NaN &&
    s.num2 != Double.NaN &&
    s.num1 != Double.NaN)
    AllN(s.num1, s.num2, s.num3, s.num4);
    else if (s.num4 == Double.NaN &&
    s.num3 != Double.NaN &&
    s.num2 != Double.NaN &&
    s.num1 != Double.NaN)
    AllN(s.num1, s.num2, s.num3);
    else if (num4 == Double.NaN &&
    num3 == Double.NaN &&
    num2 != Double.NaN &&
    num1 != Double.NaN)
    AllN(num1, num2);
    else if (s.getNum4() == Double.NaN &&
    s.getNum3() == Double.NaN &&
    s.getNum2() == Double.NaN &&
    s.getNum1() != Double.NaN)
    AllN(num1);
    else if (s.getNum4() == Double.NaN &&
    s.getNum3() == Double.NaN &&
    s.getNum2() == Double.NaN &&
    s.getNum1() == Double.NaN)
    AllN();
    }// end SortAll
    public void AllN() {
    snum0 = "There are no numbers to sort";
    public static void main (String args[]) {
    Sort n1 = new Sort();
    n1.setNum1(13);
    n1.setNum2(14);
    n1.setNum3(15);
    n1.setNum4(16);
    n1.SortAll(n1);
    Sort n2 = new Sort();
    n2.setNum1(57);
    n2.setNum2(34);
    n2.setNum3(50);
    n2.SortAll(n2);
    System.out.println(n1.getSecond());
    System.out.println(n2.getFirst());
    } // End Main

    double v = 5.0;
    if (v == v) {
      System.out.println("v is a number: "+v);
    } else { // (v != v)
      System.out.println("v is not a number: "+v);
    // or
    if (Double.isNaN(v)) {
      System.out.println("v is not a number: "+v);
    } else {
      System.out.println("v is a number: "+v);
    }

  • Help with double and float

    I added the (float) after the = in both and it fixed the top and not the bottom. "cant convert double to float" (as well as the answer to this, if somone could correct my terminology as well it would be appretiated. thanks in advance)
    float torontoF = (float)(torontoC * 1.8) + 32;
         System.out.print (torontoF);
    x      float stockholmC = (float)(stockholmF ? 32)* .5556;
         System.out.print (stockholmF);

    Reposted and answered at:
    http://forum.java.sun.com/thread.jspa?threadID=5219089
    Do not reply here.

  • 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

  • I need help with event structure. I am trying to feed the index of the array, the index can vary from 0 to 7. Based on the logic ouput of a comparison, the index buffer should increment ?

    I need help with event structure.
    I am trying to feed the index of the array, the index number can vary from 0 to 7.
    Based on the logic ouput of a comparison, the index buffer should increment
    or decrement every time the output of comparsion changes(event change). I guess I need to use event structure?
    (My event code doesn't execute when there is an  event at its input /comparator changes its boolean state.
    Anyone coded on similar lines? Any ideas appreciated.
    Thanks in advance!

    You don't need an Event Structure, a simple State Machine would be more appropriate.
    There are many examples of State Machines within this forum.
    RayR

  • Plese help me ! can't open files with double clicking icons...

    at the first, sorry about my English. (i'm japanese and english is my second language so..) anway.... i can't open the files on desk top by double click. if i go to Finder then i can open files... and some files i can open by double click. i downloaded Limewire but i can't install it because my couble click is not working for that. but i can double click to open photoshop, safari or email or some other things in the dock. and i couldn't open up the games either.. doesn anybody knows what's happened to my son's computer? it's a iMac flat panel G4. and OS X 10.3.9. Thank you sooo much!!

    Saw your response and started to write to you for help also but have, with one final try, found PART of my problem. I have a Logitech wired optical mouse that worked with everything except opening desktop volumes when I double clicked on them. I could open applications and documents within the Finder window....just not the desktop volume icons.
    I ran Disk Utility........verified all the volumes........repaired all permissions, unplugged mouse and reset. Logitech software is up to date.. I've never had this happen before.
    What I discovered was that I was double clicking to open the volumes, but had the mouse set for single click. It's still a little strange because I changed it to double click to open and now it opens with double OR single click. Now I can open the volumes but it won't allow me to move the Finder windows that open. I can't drag or move them on the desktop; have to use them where they open.
    Any suggestions for me, I hope? Thanks.

  • Help needed with doubles and integers

    I just want to start telling all you that you have been a big help to me the last couple of months. Now, for my issue. I'm having a problem doing some work with doubles and integers. Below is the code I've tried. But, I keep getting mismatch types. I need num3 to fill in a JTextField by the end with the answer for the calc. Num2 is fill in from a JTextField with a double.
    Int num1 = 0, num4 = 0, num3 = 0;
    double num2 = 0, totint = 0;
    for(count = 0; num4 < count; count++)
    totint = (1 + num2);
    System.out.println(totint);
    num3 = double (num1 * totint);
    String k = Integer.toString(num3);
    tf3.setText(k); (This is a JTextField)
    Test data
    num1 = 10000
    num2 = 3.4
    num4 = 4
    num3 = the value from the calc

    First of all, your for loop is never going to run.
    for (count = 0; num4<count; count++)
    totint = (1 + num2);
    System.out.println(totint);
    num4 = 4 and will not be less than count, so the for loop will not be executed.
    Second, what exactly are you trying to accomplish here. The way you have your code set up, the for loop (if it were to execute) would print out 4.4 each time it passes, then do the calculation. You may need to rethink your objective.

  • [svn] 1991: Also reducing HexEncoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac as part of fix for SDK-15232 .

    Revision: 1991
    Author: [email protected]
    Date: 2008-06-06 19:05:02 -0700 (Fri, 06 Jun 2008)
    Log Message:
    Also reducing HexEncoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac as part of fix for SDK-15232.
    QE: Yes, please test mx.utils.HexEncoder with ByteArrays larger than 64K on PC and Mac too.
    Doc: No
    Checkintests: Pass
    Bugs:
    SDK-15232
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-15232
    http://bugs.adobe.com/jira/browse/SDK-15232
    Modified Paths:
    flex/sdk/branches/3.0.x/frameworks/projects/rpc/src/mx/utils/HexEncoder.as

    I'm having this same issue. I also have this line in my log, which is curious:
    12/14/14 7:13:07.822 PM netbiosd[16766]: Attempt to use XPC with a MachService that has HideUntilCheckIn set. This will result in unpredictable behavior: com.apple.smbd
    Is this related to the problem? What does it mean?
    My 2010 27" iMac running Yosemite won't wake up from sleep.

  • [svn] 1990: Reducing Base64Encoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac .

    Revision: 1990
    Author: [email protected]
    Date: 2008-06-06 18:53:36 -0700 (Fri, 06 Jun 2008)
    Log Message:
    Reducing Base64Encoder buffer size from 64K to 32K to help with the smaller stack size of the AVM on Mac.
    QE: Yes, please test mx.utils.Base64Encoder with Strings and ByteArrays larger than 64K on PC and Mac after these changes.
    Doc: No
    Checkintests: Pass
    Bugs:
    SDK-15232 - mx.utils.Base64Encoder.encodeBytes "toString()" or "flush" produces 1511 error on MAC
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-15232
    Modified Paths:
    flex/sdk/branches/3.0.x/frameworks/projects/framework/src/mx/utils/Base64Encoder.as

    You can go with these options :
    http://musewidgets.com/collections/all/products/responsive-image
    http://musewidgets.com/collections/all/products/responsive-images
    Thanks,
    Sanjit

  • HT201318 Need help with being double charged on my icloud account when purchasing extra storage for my ipad

    Need help with being double charged on my icloud account when purchasing extra storage for my ipad?

    I had this same problem on my 4S. I fixed it by restoring the phone to factory defaults. Previously, I had taken the additional step of restoring from backup but, as soon as I did, the problem returned. The fix is a hassle as I now have to reinstall my apps but at least I can manage mail on the phone.
    The problem also occurred on my iPad2 but I'm not restoring it as it's a serious hassle (see above) and I don't actually read much mail on the device.
    As a side note, I noticed incredibly high load averages (5+ processes for 1, 5, and 15 minutes; 12+ for 1 and 5 minutes at one point) as well as CPU usage that didn't drop below 15% (apparently all user processes, system seemed to be about normal). As could be expected, this also lead to incredibly rapid battery depletion.
    I can't tell what processes were hogging the CPU as neither of my devices are jailbroken and Apple doesn't seem to like 'top' much.

  • 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.

Maybe you are looking for

  • Error while schedulingg update stat in db13

    Dear Experts, Please look into my issue we are facing an error while scheduling update statistics in db13 and I tried to open detailed log It is given SXPG_COMMAND_EXECUTE failed for BRTOOLS - Reason: program_start_error: For More Information, See SY

  • Ipod not recognised by mac or itunes and won't restore

    i think this is a very similar problem to everyone else but i can't find a helpful answer so i'm going to outline my situation to see if anyone can help. to start with my ipod was ok, then when i plugged it in to load new songs on it my mac and itune

  • Backing up Contacts from Samsung Galaxy S4 to Macbook Pro Retina

    Hi, I'm going to change samsung phones and I need to back up my contacts. I have a Samsung Galaxy S4 and a Macbook Pro Retina, Late 2013, with Mavericks. When I try to back up the contacts through bluetooth the phones pair up but connection is can ne

  • Write file in UTF-16BE Format

    I am programming web page that runs SWF file (Flash movie) and servlet. The SWF file sends with URL command data to the server.      send_lv.sendAndLoad("http://�", result_lv, "POST");The data at � UTF-8 (UTF-8 is the standard encoding for exchanging

  • [G505s]Trouble connecting to internet (wireless)

    Hi everyone, I am having some trouble with my laptop, at home where I use this device I always use a wireless connection. My phone, Nintendo systems and XBOX have no problems with it. But for some odd reason my laptop has only two of the 5 stripes of