Making animation using java, need help, image doesn't get painted

I was trying to make some sort of animation and it is done by painting a head and a body at a time. The problem is the body never gets painted but the head is perfect. Unless I replace the int variable within imgBodypics[int variable] with a variable at counts from 0 to N or an integer , the body doesn't get painted, that is not what i want, as the images that make up the animation consists of 8 frames starting from the image006.gif ~ image014.gif
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Color;
public class Knight extends java.applet.Applet implements Runnable {
     Image imgBodypics[]= new Image[115];
     Image imgHeadpics[]= new Image[15];
     Image imgCurrentbody, imgCurrenthead;
     int intBodyposx,intBodyposy,intHeadposx,intHeadposy;
     int brainwalkxpos,brainwalkypos,bodywalkxpos,bodywalkypos;
     Thread thdRunner;
     public void init() {
          for (int i=0;i < 115; i++){
               imgBodypics[i] = getImage(getCodeBase(),"images/knight/knight000"+i+".gif");
          for (int i=0;i < 15; i++){               
               imgHeadpics[i] = getImage(getCodeBase(),"images/headboy02/headboy02000"+i+".gif");
     public void start() {
          if (thdRunner == null) {
               thdRunner = new Thread(this);
               thdRunner.start();
     public void stop() {
          if (thdRunner != null) {
               thdRunner.stop();
               thdRunner = null;
     public void paint(Graphics g) {
          g.drawImage(imgCurrentbody, intBodyposx, intBodyposy,this);
          g.drawImage(imgCurrenthead, intHeadposx, intHeadposy,this);
     public void walk(int intNumtimes, String strDirection) {
     int intDirectionx,intDirectiony,intBodyimagecode;
          if (strDirection == "down")      {     intDirectionx = 0;
                                                  intDirectiony = 1;
                                                  intBodyimagecode = 6;}
          else if(strDirection == "leftdown"){intDirectionx =-1;
                                                  intDirectiony =1;
                                                  intBodyimagecode = 14;}
          else if(strDirection == "left") {     intDirectionx = -1;
                                                  intDirectiony = 0;
                                                  intBodyimagecode = 22;}
          else if(strDirection =="leftup") {     intDirectionx =-1;
                                                  intDirectiony =-1;
                                                  intBodyimagecode = 30;}
          else if(strDirection == "up")      {     intDirectionx = 0;
                                                  intDirectiony = -1;
                                                  intBodyimagecode = 38;}
          else if(strDirection =="rightdown") {intDirectionx =1;
                                                  intDirectiony =1;
                                                  intBodyimagecode = 14;}
          else if(strDirection == "right") {     intDirectionx = 1;
                                                  intDirectiony = 0;
                                                  intBodyimagecode = 22;}
          else if(strDirection =="rightup") {     intDirectionx =1;
                                                  intDirectiony =-1;
                                                  intBodyimagecode = 30;}
          else{      intDirectionx = 0;
                    intDirectiony = 0;
                    intBodyimagecode = 6;}
          int intLastBodyimagecode = intBodyimagecode + 8;
          int intFirstBodyimagecode = intBodyimagecode;
     for (int intCount = intNumtimes; intCount > 0; intCount--){
          for (int i = 0; i < 8; i++){
          int intJ,intI;
          intJ = i;
          intI = intBodyimagecode + i;
          imgCurrentbody = imgBodypics[intI];
          intBodyposx = 250 - (imgCurrentbody.getWidth(this) / 2) + (intDirectionx * intJ * 12);
          intBodyposy = 200 - (imgCurrentbody.getHeight(this) / 2) + (intDirectiony * intJ * 12);
          imgCurrenthead = imgHeadpics[intJ];
          intHeadposx = 250 - (imgCurrenthead.getWidth(this) / 2) + (intDirectionx * intJ * 12);
          intHeadposy = 200 - (imgCurrenthead.getHeight(this) / 2) + (intDirectiony * intJ * 12);
          repaint();
          intBodyimagecode++;
          try { Thread.sleep(200); }
          catch (InterruptedException e) { }
     public void update(Graphics g) {
     paint(g);
     public void run() {
          setBackground(Color.lightGray);
          walk(1, "left");
          walk(1, "right");
          walk(1, "up");
          try {Thread.currentThread().sleep(5000);}
          catch (InterruptedException e) { }

Erm, i tried to highlight the code and then press the code tag but after posting it is still plain, and there is no way to edit the post, sorry about that, next time i'll try. About the book "Filthy Rich Clients", no i don't have it, is there any free version of similiar resources?
testing123

Similar Messages

  • I can't get the product i bought need help NOW doesn't let me connect when i have good internet

    i can't get the product i bought need help NOW doesn't let me connect when i have good internet

    [personal information should not be posted - https://forums.adobe.com/docs/DOC-3731]
    [This is an open forum, not Adobe support, please do not post personal information]
    https://www.adobe.com/account.html to check your subscriptions
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Some general information for a Cloud subscription
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

  • All of my photos are displayed as BW because somehow I've saved a quick develop preset and it saves as BW.  This is for all of my photos.  I can individually undo them but need help in how to get rid of the preset so it goes to Default. thanks

    All of my photos are displayed as BW because somehow I've saved a quick develop preset and it saves as BW.  This is for all of my photos.  I can individually undo them but need help in how to get rid of the preset so all photos goes to Default or as shot. thanks

    Go to the develop module and highlight all of the images in the filmstrip at the bottom of the screen. Then activate Auto-sync and click on the Reset button. That should reset all of the images to your camera default settings.

  • How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    Try asking at ifixit.com. The iPhone is not considered user servicable. You're not going to get much help on an Apple sponsored forum.

  • I have an itouch, most songs i got off my cd's. i have a new laptop and want to put songs from itouch to laptop.I can only get the songs that i purchased onto the laptop? need help with how to get the rest from itouch to laptop please??

    i have an itouch, most songs i got off my cd's. i have a new laptop and want to put songs from itouch to laptop.I can only get the songs that i purchased onto the laptop? need help with how to get the rest of the songs (from my cd's) from itouch to laptop please??

    See this previous discussion:
    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • Making movies using Java

    Hi,
    I am trying to make movies using Java, and naturally with Java Media Framework it is doable. However, it is a huge overhead to my tiny tool to be distributed over the Internet, and also makes the program very hard to install for my end users, so I cannot use it.
    In essence, what need to do is to take a series of jpeg images generated by my program, and convert them into a movie. Preferably to mpeg-1.
    It only needs to work on Windows platforms, so I have been looking for a command line tool I can call from my Java program that will automatically compress the jpeg files.
    Do you have any pointers? Help would be greately appreciated, as I have been looking near and far for such a program.
    Thank you...

    Although I can't offer any help, I'd be interested to see where you go with this topic. I had a request for a program to sequence JPEG and TIFF images (taken from a E.Microsope) into movie sequences a while ago. Similar kinds of limitations. Are there any C libraries in existance that you could call into using JNI?

  • Web Guy Using Swing - Need Help With jComboBox

    I'm new to doing desktop Java development (come from a web application background) and am trying to accomplish migrating some of a web application's functionality to a desktop app for distribution. I'm already a bit stuck when it comes to using the jComboBox. What is intuitive to me in the web world would be to have one combo box/select box that after making a selection, it returns it's value so I could use that to run another query that would populate the next drop down menu. Populating the display of the combo box isn't the problem, that seems easy enough, but what I so far can't find is how I can attach a value to the combo box; that is for instance, having the drop down show a list of country names, and needing to have that list of country names correspond to a country code. For the web, you'd just have the option value tied to the code and the contents of the option be the name.
    Is this do-able? Am I completely thinking about this in the wrong way when working in desktop GUI things? I am using NetBeans 6.0 for my GUI layout and such, don't know if that helps or hurts matters. Also currently using Java 1.5.
    Any information or points in the right direction are greatly appreciated.
    Cheers.

    If I understand you correctly, you need to have a class that holds country name and country code, with a toString override method that returns just the country name (this is what the combobox shows). You then put an array of these objects in your jcombobox, obtain the selected object, get it's country code, and you're off and running.
    Edited by: Encephalopathic on Mar 31, 2008 3:26 PM

  • Hi, i'm new to java. need help setting the path in win XP

    hi all,
    i'm new to java technology. i've just downloaded the JDK and ran my first java program (hello world). i love it. java's gr8. i need help. i run win XP and how can i setup the path sothat i can execute my programs from the root dir??? any help in this direction will be greatly appreciated. please email me @ [email protected]
    Best regards
    Mrinal

    Go to Start menu and select Control Panel. In the Control Panel, double click on System. In the System dialogue, choose the Advanced tab. Then click on Environmental Variables. Select Path and Edit. Put ;c:\j2sdk1.4.0\bin at the end of the Path (or c:\j2sdk1.4.0\bin;) at the start of the Path. That's it.

  • XML tools for Java (need help getting started)

    Hi,
    I have been using Java for some time. However, I am new to XML and the tools Java has available to utilize such data.
    What packages, classes, etc are available to read and write XML data?
    Thank you in advance. Happy holidays.
    Cheers,
    Christopher

    I've been using a third-party library called JDOM for well over two years and I highly recommend it for your XML processing needs. It recently reached its first productions release and is available for download at http://www.jdom.org.
    Shaun

  • New to java(need help on access specifier)

    hi! i am new to java.plzzzzz help me i have to make a project on access specifier's i know all theroy.but
    i am unable to understand how i can define all specifiers practicly.i mean in a program.
    thanks.plzzzzzzzz help me

    the most common project i can think of is a payroll system..
    you can have real implementation of all the access specifiers
    good luck

  • Need help iNSTALLING cr2008..GET "FAILED TO REGISTER" ERRORS

    I need help regarding installing CR2008/Visual Advantage. I had the evaluation copy of cr2008. My compnay purchased the CR2008 Visual Advantage. Upon calling your customer service, I was told that I had to UN-install the CR2008 evaluation copy then install the CR2008. I did the unstall HOWEVER, when I try to install the CR2008 that we purchased, i get the following error..HR
    HR -2147024770-"c:\program files\business objects enterprise 12.0\win32_x86\REPORTCONVTOOL.DLL FAILED TO REGISTER"..
    I get more that just that one...I have received this before and based upon this formum, i have delted the regristry in the following using regedit.exe
    HKEY_LOCAL_MACHINE\SOFTWARE\BUSINESS OBJECT ;
    HKEY_CURRENT_USER\SOFTWARE\BUSINESS OBJECTS..
    Afeter i deleted the keys, I re-boot my pc and try to install the coftware again...BUT I GET THE SAME ERRORS...I have tryied this several times....what am i missing/not doing correctly

    I would suggest making sure your machine is clean.  Contact support for the steps to fully uninstall CR.  For example, here are notes to uninstall previous versions of CR:
    1218535 - How to manually uninstall Crystal Reports XI
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313338333533333335%7D.do
    1216945 - How to manually uninstall Crystal Reports 10
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313336333933343335%7D.do
    1216947 - How to manually uninstall Crystal Reports 9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313336333933343337%7D.do

  • Need help from Jeff in getting CC desktop application

    Jeff, I was unable to find my previous question to you from the other day. To start over, my CC desktop application is gone missing after 10 months of CC usage.  I need to  download a LR update so I can use my camera with raw files. How can I get this back? Apparently Adobe doesn't allow reinstalling of individual programs even though I actually own LR. Please redirect me accordingly. I need help. I have win 7 64.
    GeneC

    Genec2 locking this discussion and will respond in CC desktop app icon missing.

  • I need help with my phone getting it out of recovery mode

    i need help getting my iphone out of recovery mode

    Placing your device into recovery (DFU-Device Firmware Upgrade) mode:
    Follow these steps to place your iOS device into recovery mode. If your iOS device is already in recovery mode, you can proceed immediately to step 6.
       1. Disconnect the USB cable from the iPhone, iPad, or iPod touch, but leave the
           other end of the cable connected to your computer's USB port.
       2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds
           until the red slider appears, then slide the slider. Wait for the device to turn off.
                  * If you cannot turn off the device using the slider, press and hold the
                    Sleep/Wake and Home buttons at the same time. When the device turns off,
                    release the Sleep/Wake and Home buttons.
      3. While pressing and holding the Home button, reconnect the USB cable to the
           device. The device should turn on. Note: If you see the battery charge warning,
           let the device charge for at least ten minutes to ensure that the battery has some
           charge, and then start with step 2 again.
      4. Continue holding the Home button until you see the "Connect to iTunes" screen.
           When this screen appears you can release the Home button:
      5. If necessary, open iTunes. You should see the following "recovery mode" alert:
      6. Use iTunes to restore the device.
    If you don't see the "Connect to iTunes" screen, try these steps again. If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.
    Additional Information:
    If you have a problem getting into recovery mode then try: RecBoot: Easy Way to Put iPhone into Recovery Mode.
    Note: When using recovery mode, you can only restore the device. All user content on the device will be erased, but if you had previously synced with iTunes on this computer, you can restore from a previous backup. See this article for more information.

  • HT204382 music files that I'm trying to transfer from my external hard drive!!! i really need help! i am getting very frustrated. plz help me thank you

    hi. i am trying to transfer my old pictures and music files from my external drive into my new laptop.and first of all only a coupleof my foldersare coming up.and even those few files/folders wont play ....i am new to mac.i REALLY need help. my old pictures and music are real important to me.plz help me.

    IS the external HD from another Mac or a PC?

  • How to use Crystal Report with Java - need help

    Dear everyone,
    i am completely new to Crystal report , please can anyone help me to creat a very simple Report using the Crystal report,
    the report will show some records from oracle DB.
    How can i make it by a simple example and with code please?
    do i need any JAR or Bean for Crystal report?
    thanks for your help and please don't hesitate to contact me in case of any inquiries.
    my email: [email protected]
    Thanks in advance

    I what to use Crystal report to generate report.My programe in java swing .Iam retrive table from database in Jtable .But when giving print
    command its print half screen .so that why I wantto usecrystal report
    package file2;
    import file2.choice;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.util.*;
    import java.awt.print.*;
    import javax.swing.table.*;
    import com.sun.java.swing.*;
    import javax.swing.JTable;
    public class cour extends JFrame implements Printable
         //Menu fileMenu;
         public static void main(String[] a)
    cour n = new cour();
    n.setVisible(true);
    public cour()
         super("Course Report");
         report();
         protected void report()
              JPanel panel = new JPanel();
         JButton printButton = new JButton("Print");
         panel.add(printButton);
         JButton exitButton = new JButton("Exit");
         panel.add(exitButton);     
         DefaultTableModel defaulttablemodel = new DefaultTableModel();
              JTable jtable = new JTable(defaulttablemodel);
              panel.add(new JScrollPane(jtable));
              String      tempname="";
              int tempcnt;
              String driver="sun.jdbc.odbc.JdbcOdbcDriver";
              String url="jdbc:odbc:regs";
              Object[] data = new Object[4];
              try
                             Class.forName(driver);                         
                             Connection connection=DriverManager.getConnection(url,"sa","");
                             Statement statement = connection.createStatement();     
                             String query = "SELECT courseid as CourseID,coursen as CourseName,cfee as Fee,coursed as Duration FROM course";
                             ResultSet rs = statement.executeQuery(query);     
                             ResultSetMetaData rmeta = rs.getMetaData();
                             int numColumns=rmeta.getColumnCount();                         
                             for(int i=1;i<=numColumns;i++)
                                  if(i<=numColumns)
                                       defaulttablemodel.addColumn(rmeta.getColumnName(i));
                             while(rs.next())
                                  for(int i=1;i<=numColumns;++i)
                                       if( i<=numColumns)
                                            tempname = rs.getString(i);
                                            tempcnt=i-1;
                                            data[tempcnt] = tempname;          
                                  defaulttablemodel.addRow(data);                              
                   catch(Exception ex)
              printButton.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent ae)
              /*if(ae.getActionCommand().equals("Print"))
              PrinterJob pj = PrinterJob.getPrinterJob();
              pj.setPrintable(cour.this);
              if (pj.printDialog())
              try
              pj.print();
              catch (PrinterException pe)
              System.out.println(pe);
    exitButton.addActionListener(new ActionListener()
         public void actionPerformed(ActionEvent ae)
              choice ch=new choice();
                   setVisible(false);
                   ch.setVisible(true);
    setContentPane(panel);
         setSize(1040,780);
    /*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = getSize();
    int x = (screenSize.width - frameSize.width) / 2;
    int y = (screenSize.height - frameSize.height) / 2;
    setLocation(x, y);*/
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    public int print(Graphics g, PageFormat pf, int pageIndex)
    if (pageIndex != 0) return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pf.getImageableX(), pf.getImageableY());
    getContentPane().paint(g2);
    return PAGE_EXISTS;
    }

Maybe you are looking for

  • Upgrade to 11.2 / 11.1 with ASM from 9.2.0.5

    Hi, What are the options available to upgrade the database from 9.2.0.5 to either 11.1 / 11.2 with ASM. I know that we can upgade the following. But, how to do with ASM 9.2.0.5 -> 11.1 9.2.0.5 -> 9.2.0.8 -> 11.2 Thanks in Advance, -KarthicK

  • How renumber footnotes at the beginning of each chapter?

    Hi! I work in Indesign 6 with very large books in which the author continually add text and pages make me travel pages, each chapter should begin with footnote number 1. If I do with these sections do not move when I add pages and I have to update a

  • Killing report using Killjobid in reportserver 10g hidden?

    Dear All, Actually i want to kill a running report in the report server by clicking such a button that have already the jobID. whithout opening the reportserver page so that no body see any other reports running. like in this example: Declare L_URL V

  • Exception Message Numner in transaction MD04

    Hello, There is a field Exception Message Number on screen of transaction MD04. On my report i need to display the exception message number for corresponding MRP data element. Which tables do i need to access and the flow? regards Nishant PS : points

  • WLC downgrade

    I currently have 4400 series and 2000 series controller which are running 4.2.176 code. I have purchased some 2112 and 2125 but they have come with 5.2 code, is there a way to downgrade them to 4.2.176? I haven't been able to find this code on the CC