Double double problems...

Ok, I want to do simple opperations with my Double values, I want to be able to divide two Double variables:
Double temp1, temp2, result;
            for(int k = 0; k < Array2.length; k++) {
                temp1 = Array1[k];
                temp2 = Array2[k];
                if(temp1.compareTo(temp2) < 0) {
                    result+=(temp1/temp2);  // <----where i get this error "operator / cannot be applied to java.lang.Double,java.lang.Double"
                sum++;
            }

If I can't do that then how do I convert my Double Array so that I can read it into a normal double temp1?
Suggestions?
    double temp1, temp2, result;
    Double[] Array1, Array2; <- this has to be Double.
                // How can I convert the Array Double so I can read it to double then.
                temp1 = Array1[k];
                temp2 = Array2[k];

Similar Messages

  • IE margin doubling problem

    I am working on a site. I have a floated horizontal list of items at the very top of the header. It looks fine in Firefox and Safari but in IE 8 it forces the last item on to a second line. I have read about the margin doubling problem with IE and I've tried all sorts of ways to keep this from happening but can't seem to figure it out.
    http://www.prospectrealty1.fatcow.com/index.html
    any help on how I can keep the floated list all on one line in IE will be very much appreciate.
    thanks!

    markf12 wrote
    The problem is with the line of text (address, phone, etc) at the very top of the header, not the nav. It looks fine in Firefox and Safari but not in IE. I believe it's because of the IE margin doubling that I have learned about. I've got the string of text/ bullet list so it fills the space with 20 px space on each end. When IE adds extra margin it forces the last item (email address) down onto a second line. 
    I'm thinking of replacing all but the email address with a jpg image. Leaving the email address as a link that can be clicked. I was hoping to find a fix for this IE problem so I could keep it all as text which is a better practice as I understand it.
    Oh ok I didnt see that because in Adobe Browser lab the text is showing all on one line in IE7, IE8 and IE9 so it would be difficult for me to diagnose.
    I can tell you though it has nothing to do with double margin bug as IE8 and IE9 corrected that. It was only present in IE7 maybe and certainly in IE6. However having said that the IE double margin bug only occurred when you had a floated element which had a margin applied to it in the same direction as the float, i.e. if you floated an element left and then attached a left margin to that element also the margin would double. The solution was to add display: inline; to the elements css selector BUT you have no left margin set on the <li> tag.
    It is most likely as Nancy points out an engine difference in the way IE browsers size the text. Does this occur if you use px instead of em? If not use px....I never use em myself as I've found it does cause issues ocassionally. Also its not good practice to fill a whole horizontal line with text information where you want its visual appearence maintained, very bad. Horizontal menus never work and lines of text never do either. The art of designing a webpage is allowing enough space so the text can 'grow' into in the case when a browser interprets the text size slightly differently. Obviously that's difficult if you are re-creating this webpage build for some designer who has little knowledge of good web design practices.
    In cases where a client is absolutely definitive that they want too many links in a horizontal menu or a line of text, which must remain on one line, I would have no hestitaion about using an image. Just give the image an 'alt' and if the image is surrounded by an anchor tag give that a 'title' tag. That will keep your page 'user' friendly for those who have a disabilities.

  • GreenSock Doubling Problem (Bug?)

    I've run into an issue where if I set the visibility to an object that is being tweened to 1, GS creates a second instance of the object.
    In the attached file, click the 'btn' and notice that a 2nd row of envelopes is created and they are not blitted like the original instance.
    Bug or operator error?
    Thanks.
    www.thepixelfarm.com/tmp/GS_doublingProb01.zip

    This is NOT a bug. See the answer in the GreenSock forums:
    http://forums.greensock.com/topic/6163-greensock-doubling-problem-bug/

  • Double problem in string conversion

    I'm working on a web application. (this questions is not we related.. just giving some background to the problem) I populate a number of fields in a bean back in my business logic as Decimals. Then going up a level I do all the data manipulate I need to for display purposes and store the values as a String inside my bean. Then I pass that bean on to my jsp and it displays my values....
    Now the problem I just realized I have is that in some cases the decimal values are larger then 8 digits in length. So when I convert to a string by saying decimalVariable+""
    I end up with an exponential value.
    There are several solutions to this... but the problem is that I have thousands of places this is being done... so instead of going in and changing every decimal to a bigDecimal or going in and changing the way I convert to a string in each place, I wanted to know if I could change the toString method for Decimal.. and how to go about doing that...

    As far as being bad code... I'm keeping my mouth shut on that one.. because I've been known to do the same thing.. I just can't believe we have made it so far
    into development without this being brought to anyone's attention.Didn't mean to offend you on the bad code. :) I thought the same ("how did it go so long?") when I found our problem (and many other problems in our code).
    So my options are pretty much
    1. change all double to BigDecimal
    2. use numberFormatter anywhere it is being
    converted to a string... or actually anywhere where
    the number can possible be longer then 7 characters
    long....Use a number formatter (such as DecimalFormat) everywhere. No need to figure out whether it is needed in each case.
    I think the best solution would be to switch to BigDecimal.. but that would take a MAJOR amount of
    work... I think there are around 6K java files in this project... probably every single one of them uses a double somewhere in the class...
    hmmm July 1st Beta test deadline might be hard to meet :)Same reason why we're stuck on Java 1.3.1 at work...deadlines and possible regression issues. :(

  • Double Problem

    I am recently unable to download anything from the App Store.
    It just fails to download... all the time.
    Some days ago, I was sent an email verification mail; but whenever I try to verify, it says they are unable to verify the link I am using.
    What should I do?

    The problem is likely with the way the double is being formatted & displayed, not its actual binary value. Find the code where the double is converted to the string, and figure out who's doing the formatted (java.text.DecimalFormat?). That should point you in the right direction.

  • JAXB Marshalling of "double" problem - exponent is in the way

    An element declared as "xsd:double" in the schema is marshalled by JAXB as "3.000404E-4" to represent 0.0003000404 . When I try to process this XML document using XSLT, the standard number() function returns "NaN" because of the exponent in the representation of the number.
    Is there any way to have JAXB marshall this number in a way that is acceptable to XSLT?
    Thanks,
    -Allan

    This seems to have a solution by using JAXB custom bindings. See http://forum.java.sun.com/thread.jsp?forum=34&thread=507037
    Thanks anyway.
    -Allan

  • Can anyone please explain this double problem?

    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              System.out.println(c+a+b);
              System.out.println(d+c);
    }Result:
    3.5999999999999996
    0.6
    Why does the first println statement return 3.5999999999999996?
    Cheers

    import java.text.DecimalFormat;
    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              double f=c+a+b;
              DecimalFormat df=new DecimalFormat("#.##");
              System.out.println(df.format(f));
              System.out.println(d+c);
    this is enougn for u man..
    do sme experiment wit it

  • Double problem truncating

    Hi !!
    I've a function that works so:
    public double calibrate ( int d )
    double value = Math.pow( 2, -21 );
    return ( d * value );
    Suppose that d is 47614.
    Function must return 0.02270412445068359375 but
    output is 0.022704124450683594. Why ?
    Can I control truncating and rounding ?
    My target is that the function return 0.02270412445068359375
    Can anyone help me?
    Thanks.

    And now you request a finders fee and a place in the
    MySql hall of fame -:) Woohoo! My life's ambition achieved! ;)
    No just kidding. I found the
    same reference independenly using AltaVista, and
    formulated my first reply without knowing about your
    reply. But okay, I hereby acknowledge you as the
    original finder of this link in this thread.Heh. No, I figured you hit it independently - I was mostly just amused at the coincidence.
    Use Google - it's faster, and -you'll- get the finder's fee next time! ;)
    Grant

  • B540p double problem: loud noise and not working touch! Help please!

    Hello! I've bought an IdeaCentre B540pa (57314172) just 5 days ago. And suddenly two problems appeared. 1) My touch has ghost touching or self-touching. It's impossible to do anything. Sometimes for 5-10 minutes touch works ok, I can do things with fingers. But most of time it looks like a vertical line of self-touching fingerprints at the right side of lcd panel. 2) Even under little load my cooling fans going crazy! Diagnostic software shows diode gp (gt650m?) is overheated. Instantly temp rises till 93-95 degrees Celcium. Doesn't matter what I'm doing: surfing, or listening, or watching video. Due to something (they don't say why) local Lenovo service can't do repair. They say it's faulty motherboard and touch panel. They don't want to do a warranty repair. Instead they say to return my b540 back to shop, so the shop had that mess. But I want to try something by myself to repair, do something. 1) I opened back panels of b540 and now I see that when I push ON button to start the desktop a red diode is lighting up on touch board controller (a little board in the bottom middle). Is it normal or must be replaced? Will it solve the touch screen problem? 2) Recently I've read here at the forum, that people had similar problems with overheating. And that their problem was solved only with motherboard replacing. Is this the only solution? Of course I can return my desktop to the shop, and they will refund me. But I've paid 600$ for that b540, and there is no similar great desktops in that price range. At least in my city in Russia. They have b550 models, but they twice the price of my b540. I want to do something, make it work, and enjoy it with full specs: touchscreen, silent cooling, big screen etc. Please, help me deal with my thoughts and my b540p!

    Thanks for advice, but I have already tried to calibrate. Nothing.
    It's is very strange problem with touch. Right now, when I'm writing this the "auto-touch" or "selftouch", whatever name it, is zooming, moving page in the browser, and trying to make my life worse. The only way is to disable HID-compatible device is Device Manager. Another way is to have two or three fingers of a hand at the glass panel surface. It's strange but this action makes selftouch be under control. At least it stops zooming, moving. There is a little focus/unfocus problem, like screen is loosing and finds focus. Text goes a bit smaller, and again becomes bigger. I hope you understand what I'm trying to say.

  • Double problem: AirPort Utility 5.3.1 & Time Machine & AirPort Updater 1.0

    Few days ago. I updated the AirPort Utility 5.3.1. But then I cannot setup my old 802.11g AirPort Extreme Base Station (mushroom). AirPort Utility 5.3.1 can detect my AirPort Extreme Base Station: the name, IP Address, Version which is 5.5.1 and AirPort ID.
    Every time I clicked manual setup or continue, it reported "An error occurred while reading the configuration. Please make sure your Apple wireless device is plugged in and in range of your computer or connected via Ethernet and try again (-6765)."
    Today, more trouble. After installed the Time Machine and AirPort Updater 1.0. Not even problem not fix the problem and I can't re-install 10.5.2 update combo.
    Got error message "You cannot install Mac OS X Update Combined on this volume. This volume does not meet the requirements for this update."
    Repair disk permission help at all.
    Any methods can solve the above 2 problem please?
    Thanks

    mcdull wrote:
    Few days ago. I updated the AirPort Utility 5.3.1. But then I cannot setup my old 802.11g AirPort Extreme Base Station (mushroom). AirPort Utility 5.3.1 can detect my AirPort Extreme Base Station: the name, IP Address, Version which is 5.5.1 and AirPort ID.
    Every time I clicked manual setup or continue, it reported "An error occurred while reading the configuration. Please make sure your Apple wireless device is plugged in and in range of your computer or connected via Ethernet and try again (-6765)."
    Thanks
    I can help you with the first problem, as I experienced it myself. Airport Utiity cannot read your old "mushroom" base station until its firmware is upgraded to version 5.7. Because the Utility cannot configure it, you can download this and apply it directly:
    http://www.apple.com/downloads/macosx/apple/macosx_updates/airportextremefirmwar eupdate57formacosx.html
    Once applied, Airport Utility will configure the AEBS just fine.

  • Address Book Syncing Problems and Won't Restore

    I sync address book between two computers using .mac, and also publish it for another family member to use. This was working fine under Tiger, but I've recently noticed some issues in Leopard. Occasionally, instead of merging records, it will double them up. This morning, I noticed I had twice as many contacts as I should. For some reason, it added my entire .mac address book again back to my computer. Other times it had done that with only a few of the contacts.
    Fortunately, I had done an Archive my address book just the other day. Unfortunately, it didn't help. I went to restore from the Archive using "Import" and "Address Book Archive". It warned me it was about to replace my entire address book with the Archive, but then nothing happened. All my contacts disappeared, but then all of them came back again, still doubled. I know it was not doubled when I did the archive, so it didn't really restore my Archive.
    I finally fixed my doubled contacts problem by doing a one way sync from my second computer (which had not yet been affected by this) to .mac and then a one way sync from .mac to my laptop. I then turned off .mac syncing.
    Then, a little while later I had 20 more contacts! I realized that this came from the fact that the address book is published and the subscriber has editing rights. But she did not add them. It was again a doubling problem, this time in the sharing function. So I turned off editing in sharing.
    All is back now but I won't turn .mac syncing or shared editing back on until I understand what happened.
    Anyone else see these issues?

    leopard 10.5.1 on macbookpro. instructions to fix missing sync for my treo 650 including backing up (exporting) then restoring the address book. i also am unable to restore.
    the backup archive shows 6 MB.
    i click import, choose the archive, verify that i want to replace all. the address book then shows only the address that was highlighted before import, still shows 1152 cards, but no other cards are visible. verified the search box is empty.
    if i quit and restart address book, the original version of the address book is still there. apparently unable to import address book.
    -db

  • Swap area problem

    hello
    I don't have swaparea partition, and I want to use pm-hibernate , so I used this commands
    # fallocate -l 512M /swapfile
    # dd if=/dev/zero of=/swapfile bs=1M count=512
    # chmod 600 /swapfile
    # mkswap /swapfile
    # swapon /swapfile
    then I edited /etc/fstab
    /swapfile none swap defaults 0 0
    after that I edited /etc/default/grub (GRUB_CMDLINE_LINUX)
    GRUB_CMDLINE_LINUX="resume=/dev/sda6 resume_offset=1232896 "
    /dev/sda6 contains swapfile and I found resume_offset after using file
    [root@arch ~]# filefrag -v /swapfile
    Filesystem type is: ef53
    File size of /swapfile is 536870912 (131072 blocks, blocksize 4096)
    ext logical physical expected length flags
       0       0  1232896           32768
       1   32768  1265664           32768
       2   65536  1298432           32768
       3   98304  1331200           32768 eof
    /swapfile: 1 extent found
    in the end I used "grub-mkconfig > /boot/grub/grub.cfg "
    after all this  pm-hibernate can't work it shows me this message
    "PM : swap header not found"
    what should I do ??

    subzero wrote:
    _rmmod()
    if modprobe -r "$1"; then
    touch "${STORAGEDIR}/module:$1"
    return 0
    else
    log "# could not unload '$1', usage count was $2"
    return 1
    fi
    it says that log  was not found. and I don't think that this is a problem
    but you have reason suspend is not montionned at all in this file, I'm sure that I suspended to ram (I can make differance ^^) , perhaps pm-suspend can't writes its log !!
    I have a different opinion:
    1. It is a double-problem that "log" was not found, Why would the script be in that "else" bracket? To log that the unloading of module $1 failed.
    2. It is a log about hibernate because it says so all over the place. Compare your two pastebins to see the difference. Besides again it is old: October 2 was last Friday. You probably got the wrong log again - log problem or not.
    Try this to look at the last 200 lines of it
    tail -n 200 /var/log/pm-suspend.log |more
    Troubleshooting the reason behind suspend/resume-problems can be pretty tiresome.
    I think you should take more time to gather the information. Also you suddenly changed thread topic, which is fine, but you did so without providing information about how you configured everything around pm-utils - compare it to how you provided the relevant information for your initial question regarding swapfile.

  • I have an iMac and iphoto.  Currently I am having a problem with an album in iphoto.  When I double click on the album all I get in the main body of the screen is a triangle with an exclamation mark and my 2 photos show at the very bottom of the window.

    I have an imac and am using iphoto.  Currently I am having a problem with one particular album which shows in the main part of the window a triangle with an exclamation point.  The two photos are at the bottom of the main window in the same area where the "info" "edit" "create" area is.  I can see the two photos but I can not get them back into the main part of the window.  I can't drag them anywhere either.  I can't double click or right click on either of the two photos either. All I can do is click on either one and they get a little bigger.  Before I saw the exclamation point in the main body of the window all I get is two squares with nothing in them and the entire border is made up of dashes.  Can someone help me?

    Make a temporary, backup copy of your library if you don't already have one (Control-click on the library and select Duplicate from the contextual menu) and  apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
                                            Screenshot is for iPhoto 9
    Since only one option can be run at a time start with Option #3, followed by #4 and then #1 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.

  • Problem with the  addition of  double numbers

    when we try to add the two double numbers say,
    119.52, 10.00
    here we should get 129.52
    but it is giving as 129.51999999999998
    This is happening only for sum numbers.
    Here i want to round this to two digits after decimal point
    if i round the above value i will get 129.52 and the problem will be solved.
    But we don't know exactly on what basis we are getting the sum as 129.51999999999998.
    Assume that, tomorrow when we are adding some other numbers we may got like
    129.51444444444448
    when we round this we get 129.51
    but actually we have to get 129.52.
    If anyone know why the system is giving that wrong sum , please give solution to avoid this.
    In My application , i want the exact sum amount so if i add some numbers i should get exact sum.
    like 119.52+10=129.52
    i want exactly this. How to get this.

    As another poster said, this is a topic worth reading up on, as there are subtleties involved in this kind of imprecise math. A couple of points to get you started though...
    * Java's double type has a precision of something like 16 (20? 24?) decimal places. (You should be able to find the correct number in the lang. spec., or someone may be kind enough to post it here.) I don't remember the formal definition, but what this means, approximately, is that any number that can be represented will be accurate to within +/-0.5*10^-16 of its value. That is, if the actual value is 2e5, then the absolute value of the error in the representation will be less than 0.5e-11. (I might be off be a factor of 2 and/or an order of magnitude here, but you get the general idea.) The good news is, no value will be in error by more than that amount. The bad news is, any value could be in error by up to that amount. These are the two key points.
    * Compare the precision implicit in your data and needed in your results to that of Java, along with the number of intermediate calculations you'll do to get a final result. For instance, if you're doing financial calcs in the tens of billions of dollars, and you need accuracy to the penny, that's one part in 10^-12. Assuming any given value is off by no more than one part in 10^-16, and assuming all errors are in the same direction, if you do 10^4 cumulative additions, you'll be off by a penny. Again, these are rough, and I may have missed something, but this is the kind of thing to look at to determine how the inherent imprecision will affect you.
    * Don't round any intermediate results. Keep the precision you have. However, when you're comparing (as jschell demonstrated) make a copy of the value and round that copy before doing the comparison. Use the first two points above to determine whether that rounding will meet your needs for precision. Same goes for displaying.
    * Finally, if the 10^-16 (or whatever it was) precision of a double is not sufficient, you can get arbitrary precision with BigDecimal. There are a couple of caveats, however. 1) It's a lot slower than using primitives ans 2) Arbitrary precision does not mean infinite precision. You can specify as many decimal places as you want (subject to time and memory constraints), but you even if you specify 1,000 decimal places, you can still be off by 5 in the 1001st place.

  • Problem with Double Buffering and Swing

    Hi
    I made a game and basically it works pretty well, my only problem is it flickers really badly right now. I read up on a whole lot of forums about double buffering and none of those methods seemed to work. Then I noticed that Swing has double buffering built in so I tried that but then I get compilation errors and I'm really not sure why. My original code was a console application and worked perfectly, then I ported it into a JApplet and it still works but it flickers and thats what I'm tryign to fix now.
    The code below is in my main class under the constructor.
    Heres the double buffering code I'm trying to use, I'm sure you all seen it before lol
    public void update(Graphics g)
              // initialize buffer
              if (dbImage == null)
                   dbImage = createImage(this.getSize().width, this.getSize().height);
                   dbg = dbImage.getGraphics();
              // clear screen in background
              dbg.setColor(getBackground());
              dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
              // draw elements in background
              dbg.setColor(getForeground());
              paint(dbg);
              // draw image on the screen
              g.drawImage(dbImage, 0, 0, this);
         }My paint is right under neath and heres how it looks
    This snipet of code works but when I change the method to
    public paintComponent(Graphics g){
    super.paintComponent(g)...
    everythign stops working and get a compilation error and says that it can't find paintComponent in javax.swing.JFrame.
    public void paint(Graphics g)
              super.paint(g);
              //if game starting display menue
              if (show_menue)
                   //to restart lives if player dies
                   lives = 3;
                   menue.draw_menue(g);
                   menue_ufo1.draw_shape(g);
                   menue_ufo2.shape_color = Color.DARK_GRAY;
                   menue_ufo2.draw_shape(g);
                   menue_ufo3.shape_color = Color.BLUE;
                   menue_ufo3.draw_shape(g);
                   menue_ufo4.shape_color = new Color(82, 157, 22);
                   menue_ufo4.draw_shape(g);
                   menue_ufo5.draw_shape(g);
                   menue_ufo6.shape_color = new Color(130, 3, 3); ;
                   menue_ufo6.draw_shape(g);
                   menue_turret.draw_ship(g);
                   menue_ammo.draw_ammo(g);
              else
                   //otherwise redraw game objects
                   gunner.draw_ship(g);
                   y_ammo.draw_ammo(g);
                   grass.draw_bar(g);
                   o_ufo.draw_shape(g);
                   b_ufo.draw_shape(g);
                   m_ufo.draw_shape(g);
                   s_ufo.draw_shape(g);
                   z_ufo.draw_shape(g);
                   xx_ufo.draw_shape(g);
                   info.draw_bar(g);
                   live_painter.draw_lives(g, lives);
                   score_painter.draw_score(g, score);
                   level_display.draw_level(g, level);
                   explosion.draw_boom(g);
         }I just want to get rid of the flickering for now so any help will be greatly appreciated. Depending which will be simpler I can either try to double buffer this program or port it all to swing but I'm not sure which elements are effected by AWT and which by Swing. Also I read some of the Java documentation but couldn't really understand how to implement it to fix my program.
    Thanks in advance
    Sebastian

    This is a simple animation example quickly thrown together. I have two classes, an animation panel which is a JPanel subclass that overrides paintComponent and draws the animation, and a JApplet subclass that simply holds the animation panel in the applet's contentpane:
    SimpleAnimationPanel.java
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    class SimpleAnimationPanel extends JPanel
        private static final int DELAY = 20;
        public static final int X_TRANSLATION = 2;
        public static final int Y_TRANSLATION = 2;
        private Point point = new Point(5, 32);
        private BufferedImage duke = null;
        private Timer timer = new Timer(DELAY, new TimerAction());
        public SimpleAnimationPanel()
            try
                // borrow an image from sun.com
                duke = ImageIO.read(new URL(
                        "http://java.sun.com/products/plugin/images/duke.wave.med.gif"));
            catch (MalformedURLException e)
                e.printStackTrace();
            catch (IOException e)
                e.printStackTrace();
            setPreferredSize(new Dimension(600, 400));
            timer.start();
        // do our drawing here in the paintComponent override
        @Override
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            if (duke != null)
                g.drawImage(duke, point.x, point.y, this);
        private class TimerAction implements ActionListener
            @Override
            public void actionPerformed(ActionEvent e)
                int x = point.x;
                int y = point.y;
                Dimension size = SimpleAnimationPanel.this.getSize();
                if (x > size.width)
                    x = 0;
                else
                    x += X_TRANSLATION;
                if (y > size.height)
                    y = 0;
                else
                    y += Y_TRANSLATION;
                point.setLocation(new Point(x, y)); // update the point
                SimpleAnimationPanel.this.repaint();
    }AnimationApplet.java
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class AnimationApplet extends JApplet
        public void init()
            try
                SwingUtilities.invokeAndWait(new Runnable()
                    public void run()
                        // construct the panel
                        JPanel simpleAnimation = new SimpleAnimationPanel();
                        // put it in the contentPane of the JApplet
                        getContentPane().add(simpleAnimation);
                        setSize(simpleAnimation.getPreferredSize());
            catch (InterruptedException e)
                e.printStackTrace();
            catch (InvocationTargetException e)
                e.printStackTrace();
    }Here's a 3rd bonus class that shows how to put the JPanel into a stand-alone program, a JFrame. It's very similar to doing it in the JApplet:
    AnimationFrame.java
    import javax.swing.JFrame;
    public class AnimationFrame
        private static void createAndShowUI()
            JFrame frame = new JFrame("SimpleAnimationPanel");
            frame.getContentPane().add(new SimpleAnimationPanel());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    createAndShowUI();
    }Edited by: Encephalopathic on Mar 15, 2008 11:01 PM

Maybe you are looking for

  • HELP! After installing iTunes 7, all the songs on my iPod disappeared!

    I dont know if othe people are having this problem too but it really *****! I downloaded iTunes 7 a while back because i had no choice, i wouldnt be able to buy songs/music videos from it if i didnt. It installed a new iTunes then a new iPod upgrade.

  • (High Ip input) on My router , I need to troubleshoot why CPU is high !!!!

    (High Ip input) on My router  , I need to troubleshoot why CPU is high !!!! ================= i have a cisco router 7200 NPEG2 processor , worked as LNS for PPPOVPDN circuits (Router for ADSL clients) i  have "high ip input on my processor" and there

  • Difference between down payment & advance payment

    Hi frndzz.. I have lil' confusion on these two.   Advance payment is what you you pay to your vendor against the purchase order is raised. Later you clear this value against the invoice sent by your vendor. I see the same is applicable for downpaymen

  • How to remove word from personal dictionary?

    I've searched online for this and it almost sounds like it can't be done in DW CS5, but that just seems crazy.  I added a word to my dictionary that can be spelled two ways and now, for consistency sake, want to remove one version.   Can anyone tell

  • New value in resultlist

    Hi I had a question. I found some solution in this forum, but i do not understand. I want to add a new value to the resultlist. I had to expand the database table "STEP_RESULT" with the column "Seriennummer". How can I add this new value to the resul