No Compiling Error but doesn't work NEW

import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.applet.*;
public class javacw extends Applet implements KeyListener, Runnable
     Area pandaArea;
     Graphics2D g2d;
     // Providing coordinate control for the Panda
     int pandax=20, panday=50;
     // Animation condition. True = animate, False = static.
     boolean pandabool=false, laidOut=false;
     boolean left;
     boolean right;
     boolean up;
     boolean down;
Thread animThread;
Dimension offDimension;          // Defines an offscreen Dimension
Image offImage;                    // Defines an offscreen Image
Graphics offGraphics;          // Defines an offscreen Graphics
     Image panda;                    // Defines an Image object for panda
     public void init()
          // Set the layout of the applet to null
          setLayout(null);
          panda = getImage(getCodeBase(), "panda.gif");
          pandax=0;
          panday=0;
          addKeyListener(this);
          public void Move ()
               if (left) {
                    pandax = pandax - 10;
               if (right) {
                    pandax = pandax + 10;
               if (up){
                    panday = panday + 10;
               if (down){
                    panday = panday - 10;
          public void keyTyped(KeyEvent event){}
          public void keyPressed(KeyEvent event)
               if (event.getKeyCode() == KeyEvent.VK_LEFT) left = true;
               if (event.getKeyCode() == KeyEvent.VK_RIGHT) right = true;
               if (event.getKeyCode() == KeyEvent.VK_DOWN) down = true;
               if (event.getKeyCode() == KeyEvent.VK_UP) up = true;
               repaint();
          public void keyReleased(KeyEvent e)
               if (e.getKeyCode() == KeyEvent.VK_LEFT) left = false;
               if (e.getKeyCode() == KeyEvent.VK_RIGHT) right = false;
               if (e.getKeyCode() == KeyEvent.VK_UP) up = false;
               if (e.getKeyCode() == KeyEvent.VK_DOWN) down = false;
               repaint();
public void start()
          // Make sure the thread hasn already been created
     if (animThread == null) {
     animThread = new Thread(this, "anim");
     animThread.start();
public void run() {
          // Create a current thread.
          Thread myThread = Thread.currentThread();
     // As long as the thread is created, keep redrawing the
     // canvas and then pausing for 10 miliseconds.
     while (animThread == myThread) {
               repaint();
     try {
          Thread.sleep(10);
     } catch (InterruptedException e){}
public void paint(Graphics g)
          if (offImage != null) {
          g2.drawImage(offImage, 0, 0, null);
     // Overide the update() method
public void update(Graphics g) {
          Dimension d = getSize();
          // Create the offscreen graphics context
          if ((offGraphics == null)
          || (d.width != offDimension.width)
          || (d.height != offDimension.height)) {
          offDimension = d;
          offImage = createImage(d.width, d.height);
          offGraphics = offImage.getGraphics();
          // Erase the previous image
          offGraphics.setColor(getBackground());
          offGraphics.fillRect(0, 0, d.width, d.height);
          offGraphics.setColor(Color.black);
          paintFrame(offGraphics);               // Paint the frame into the image
          g.drawImage(offImage, 0, 0, null);     // Paint the image onto the screen
public void paintFrame(Graphics g) {
          Graphics2D g2d = (Graphics2D)g;
          g2d.drawImage(panda, pandax, panday, this);
          if (pandabool) {               // If pandabool==true, animate the panda =)
               if (pandax>400) pandax=0;
               if(pandax<0)pandax=400;
public void stop()
     animThread = null;
          offImage = null;
          offGraphics = null;
public void destroy(){}
hi everyone, i'm new to java and i'm trying to wirte a keyListener to makes my image move. btw there are no compiling errors but the key is not working. hope that someone can help me. appreciate

You have a Move() function that you're not calling! Not much use unless you place a call to it in your run() function, eh?
Next time you post code, use the  tags.

Similar Messages

  • No Compiling Error but doesn't work

    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.applet.*;
    public class javacw extends Applet implements KeyListener, Runnable
         Area pandaArea;
         Graphics2D g2d;
         // Providing coordinate control for the Panda
         int pandax=20, panday=50;
         // Animation condition. True = animate, False = static.
         boolean pandabool=false, laidOut=false;
         boolean left;
         boolean right;
         boolean up;
         boolean down;
    Thread animThread;
    Dimension offDimension;          // Defines an offscreen Dimension
    Image offImage;                    // Defines an offscreen Image
    Graphics offGraphics;          // Defines an offscreen Graphics
         Image panda;                    // Defines an Image object for panda
         public void init() {
              // Set the layout of the applet to null
              setLayout(null);
              panda = getImage(getCodeBase(), "panda.gif");
              public void keyTyped(KeyEvent event){}
              public void keyPressed(KeyEvent event)
                   if (event.getKeyCode() == KeyEvent.VK_LEFT) left = true;
                   if (event.getKeyCode() == KeyEvent.VK_RIGHT) right = true;
                   if (event.getKeyCode() == KeyEvent.VK_DOWN) down = true;
                   if (event.getKeyCode() == KeyEvent.VK_UP) up = true;
                   repaint();
              public void keyReleased(KeyEvent e)
                   if (e.getKeyCode() == KeyEvent.VK_LEFT) left = false;
                   if (e.getKeyCode() == KeyEvent.VK_RIGHT) right = false;
                   if (e.getKeyCode() == KeyEvent.VK_UP) up = false;
                   if (e.getKeyCode() == KeyEvent.VK_DOWN) down = false;
                   repaint();
    public void start()
              // Make sure the thread hasn already been created
         if (animThread == null) {
         animThread = new Thread(this, "anim");
         animThread.start();
    public void run() {
              // Create a current thread.
              Thread myThread = Thread.currentThread();
         // As long as the thread is created, keep redrawing the
         // canvas and then pausing for 10 miliseconds.
         while (animThread == myThread) {
                   repaint();
         try {
              Thread.sleep(10);
         } catch (InterruptedException e){}
    public void paint(Graphics g) {
              if (offImage != null) {
              g.drawImage(offImage, 0, 0, null);
         // Overide the update() method
    public void update(Graphics g) {
              Dimension d = getSize();
              // Create the offscreen graphics context
              if ((offGraphics == null)
              || (d.width != offDimension.width)
              || (d.height != offDimension.height)) {
              offDimension = d;
              offImage = createImage(d.width, d.height);
              offGraphics = offImage.getGraphics();
              // Erase the previous image
              offGraphics.setColor(getBackground());
              offGraphics.fillRect(0, 0, d.width, d.height);
              offGraphics.setColor(Color.black);
              paintFrame(offGraphics);               // Paint the frame into the image
              g.drawImage(offImage, 0, 0, null);     // Paint the image onto the screen
    public void paintFrame(Graphics g) {
              Graphics2D g2d = (Graphics2D)g;
              g2d.drawImage(panda, pandax, panday, this);
              if (pandabool) {               // If pandabool==true, animate the panda =)
                   if (pandax>400) pandax=0;
                   if(pandax<0)pandax=400;
    public void stop()
         animThread = null;
              offImage = null;
              offGraphics = null;
    public void destroy(){}
              public void Move ()
                   if (left) {
                        pandax-=10;
                   if (right) {
                        pandax+=10;
                   if (up){
                        panday-=10;
                   if (down){
                        panday+=10;
    i was trying to add the keylistener to makes my pic move and there are no compiling problem but it doesn't work when i press the key
    thx for everyone

    One problem might be your lack of a setVisible( true ). It would be easier to read if you put code tags around your code.

  • Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can se

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game. 

    Hello Vaidas Vaidas,
    It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    What is preventing you from changing your password? Any error messages or prompts?
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • Error mapping doesn't work for me. Plz Help!

    I have created a .war using deploytool and added "404, /WEB-INF/NoSuchPage.html" in the error mapping area in file refs on the right tabbed panes.
    When I deploy the war and test it, the error mapping doesn't work. The server still display the default 404 page to me.
    What is the problem?
    I do have checked the descriptor. It contains:
    <error-page>
    ������<error-code>404</error-code>
    ������<location>/WEB-INF/NoSuchPage.html</location>
    </error-page>
    Any help will be greatly appreciated!

    <?xml version="1.0" encoding="UTF-8" ?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>WebApp</display-name>
    - <welcome-file-list>
    <welcome-file>login.html</welcome-file>
    </welcome-file-list>
    - <error-page>
    <error-code>404</error-code>
    <location>/Error.html</location>
    </error-page>
    <jsp-config />
    </web-app>
    This is a very simple war with no component and an error page is defined. But this doesn't work. When I type something like /loginnnn.htmllll, it doesn't give me the error page. That is my problem. Any idea???

  • The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on that  wifi network

    The wifi at my school isn't very good. And I can't send iMessages through it. It works for some apps like score center and my radar app, but doesn't work for other apps like clash of clans and iMessage. How can I get it to work on my school wifi. I have an iPhone 4S on AT&T and iOS 7.04

    In a roaming network, your "main" router is the device that would require port mapping/forwarding to be configured in order to access the IP camera from the Internet. This router is also the one that would be provide the private IP address for the camera which you will want to be a static one.
    So as you described your network, the IP cameras should be getting an IP address or you assigned it a static one and this is the address that you would enter in the Private IP address (or equivalent depending on the router used) field when setting up port mapping.
    If you are not able to access this camera from the local network, then this should be troubleshot first.

  • I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I updated my iphone 5 to ios 6.0.2. my wifi says its connected but doesn't work now. It doesn't matter what wifi network I connect to. It worked before updating my phone. I can no longer use facetime or use wifi at all. I'm not sure what to do to fix it.

    I'm having similar issues with my phone.  I got my first iPhone recently, only had an iPod touch gen4 for a little over a year.  Updated to 6.0.2 when we got the phone (iPhone 5) a few days before Christmas.  When I got home on the evening of January 11, my phone would not connect the router anymore.  I was able to get it to connect after resetting the phone and the router, updating the router, and manually connecting.  That laste for a few minutes and then wouldn't work anymore.   I live in an area with very limited service, we have a network extender installed to help, and I am barely getting a 3G signal at times.
    My wife's iPad 4, my touchiPod 4, and all of our laptops are working just fine on the router.  When I dropped my kid off at school today, I noticed that I am not even seeing the school network anymore from the parking lot where before I got 3 or 4 bars and could connect to their wifi when I was there.  Today my phone goes back and forth between seeing my home network but not connecting, to not even seeing the network at all even from the same room that the router is in.
    Hope Apple fixes this problem soon..............

  • HT4314 Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I

    Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.

    Contact iTunes
    Contact iTunes

  • I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??

    I have a VGA adapter and an iPad2.  Tried projecting my iPad2 to projector using the VGA but doesn't work.  Tried it with friend's iPad1 and it works.  Why??  Pls help.

    Yup - nothing happens.  I then took the same VGA cable and plugged it into my friend's iPad1 and it worked perfectly when she opened Keynote.  My understanding is that the iPad2 mirrors the entire screen, so no need to go into any specific application in order to project to the screen, right?  Do I need to download any specific app or change any settings in order to be able to project the screen using VGA?
    Sorry - novice at this.  Not very tech minded either...

  • Live Auction has been installed, but doesn't work

    Hi experts!
    I've got a lot of errors - LAC doesn't work - Need your help!
    1: (SmokeTest):
    Make sure the Live Auction initiator's applet JAR file has been properly deployed. This file should be located at H:\usr\sap\SRN\DVEBMGS02\j2ee\cluster\server0\apps\sap.com\com.sap.srm.la\servlet_jsp\srm\root\srm\nullsrmlaInitiator5.10.0.jar.
    If you are accessing this page outside of the firewall and via a web dispatcher or reverse proxy, then make sure you can download the JAR file using the "Download" button below. Alternatively, you can try accessing this page inside the firewall to verify that the JAR file is deployed properly.
    URL=http://serverzzz.zzz.zz:8002/srm/nullsrmlaInitiator5.10.0.jar
    2: Process Bid Invitation -> Action -> Bid Comparison
        Error when processing your request
    What has happened?
    The URL http://serverzzz.zzz.zz:8002/sap/bc/gui/sap/its/BBP_BID_EVAL/! was not called due to an error.
    Note
    The following error text was processed in the system SRM : Screen output area too small
    The error occurred on the application server serverzzz_SRM_zz and in the work process 0 .
    The termination type was: ABORT_MESSAGE_STATE
    The ABAP call stack was:
    SYSTEM-EXIT of program SAPLBBP_BID_EVAL 
    What can I do?
    If the termination type was RABAX_STATE, then you can find more information on the cause of the termination in the system SRN in transaction ST22.
    If the termination type was ABORT_MESSAGE_STATE, then you can find more information on the cause of the termination on the application server serverzzz_SRM_zz in transaction SM21.
    If the termination type was ERROR_MESSAGE_STATE, then you can search for more information in the trace file for the work process 0 in transaction ST11 on the application server serverzzz_SRM_zz . In some situations, you may also need to analyze the trace files of other work processes.
    If you do not yet have a user ID, contact your system administrator.
    Error code: ICF-IE-http -c: 100 -u: PURMANAGER -l: E -s: SRN -i: serverzzz.zzz.zz -w: 0 -d: 20081031 -t: 091757 -v: ABORT_MESSAGE_STATE -e: Screen output area too small
    HTTP 500 - Internal Server Error
    3: Process Auction -> Display Company Bid  -> Live Auction
    Service cannot be reached
    What has happened?
    URL http://serverzzz.zzz.zz:8002/sap/bc/gui/sap/its/_accessibility=0 call was terminated because the corresponding service is not available.
    Note
    The termination occurred in system SRM with error code 404 and for the reason Not found.
    The selected virtual host was 0 .
    What can I do?
    Please select a valid URL.
    If you do not yet have a user ID, contact your system administrator.
    ErrorCode:ICF-NF-http-c:000-u:SAPSYS-l:R-i:serverzzz_SRM_zz-v:0-s:404-r:Notfound
    HTTP 404 - Not found
    So, first of all as far I understand path to JAR files is misconfigured. Where and how can I fix it?
    Any help will be appreciated!
    Edited by: Maxim Pak on Oct 31, 2008 4:44 AM

    I cannot explain it other than to tell you the current recommendations are to keep java turned off and there are no other posts like yours that claim they need it on (at least that I have seen).  Also I have it off on my system and flash plays with no problems in all the sites I go to (modulo some buffering problems sometimes with certain hi-res videos on only youtube).
    Did you install the latests flash player downloaded directly from the adobe site?
    Maybe you have a flash storage or cookie problem.  Those can be cleared and deleted with the Flash Player system preferences.
    It's your decision on whether you want to take your chances with Java on rather than find the root of the problem.  If you do that then at a minimum make sure you have latest apple java updates, I recommend you install and learn about Little Snitch, and use OpenDNS DNS servers (208.67.222.222, 208.67.220.220).

  • After i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    after i update the 10.10.2 OS X Yosemite my iPhoto stops working. In the warning that appears when I try to open the app says that happened a mistake because of this update. I reinstalled the app but doesn't work anyway. Please, HELP!

    I already tried that but it doesn't work. Appears a warning saying: "See the developer to make sure that iPhoto works with this version of OS X. You may need to reinstall the application. Be sure to install all available updates in the application and OS X."

  • I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    I accidently turned voice over on,I've tried triple clicking the home button to bring up voice over options but doesn't work. I can't scroll down to get to Accesibility in genereal even with three fingers.

    This article can show you how to disable it through iTunes on a PC/Mac:
    iOS: Configuring accessibility features

  • I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    I was wondering if there's a way to connect to my work server from my home iMac i7. I can't seem to get Share Screen to work. I have tried connecting to server using the vnc but doesn't work.

    The easiest way would be to use Back to My Mac, but that will only work if the server is a Mac running OS X 10.7 or later and you have the cooperation of the network administrator.
    OS X: Using and troubleshooting Back to My Mac with your iCloud account

  • Firefox crashing AND the scroll feature on my PC finger pad works with other browsers, but doesn't work on Firefox, which just happened since I updated. FRUSTRATING!

    Since I updated, Firefox is crashing daily. The finger scroll feature on my PC works with other browsers, but doesn't work on Firefox. It is also very, very slow, but other browsers aren't. I can't use it anymore until it's fixed.

    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold (user set).
    *Preferences can be reset to the default via the right-click context menu if they are user set
    *Preferences can be changed via the right-click context menu: Modify (String or Integer) or Toggle (Boolean)
    *http://kb.mozillazine.org/about:config

  • I have internet optic fiber connection and I'm trying to configure it with my Airport Express but doesn't works, appears that I have IP and DNS, as I'm a computers dummy , who could help me to configuration it, please?

    I have internet optic fiber connection and I'm trying to configure it with my Airport Express but doesn't works, appears that I have IP and DNS, as I'm a computers dummy , who could help me to configuration it, please?

    You're welcome.
    Voicemail is left at your carrier's server. That will continue to work unless you report your iPhone as lost or stolen with your carrier.
    You may never find it again and you can't if the iPhone remains offline or out of service which means the iPhone is powered off or doesn't have cellular reception.

  • HT204051 I'm unable to connect my iphone 5s to the Dlink router. I tried all the apple support suggestions. But doesn't work. Please let me know.

    I'm unable to connect my iphone 5s to the Dlink router. I tried all the apple support suggestions. But doesn't work. Please let me know.

    I'm having this problem now with my 2 weeks old iPhone 6+. in the beginning everything going great and managed to connect every wifi around me. Then suddenly 1 week ago, All the wifi from my office, home, hotel and coffee house saying either incorrect password or can't join the wifi. But when i switch on my hotspot from my iPhone 5 it can be connect. i also try with my friend iPhone hotspot. So is it because of hardware problem or software problem. And i just restore my iPhone6+ and still can't connect to wifi and manage to join hotspot (also wifi right?) regret as all my downloaded stuff vanish and now can't download back using wifi.....
    Thanks for assisting

Maybe you are looking for

  • After Effects installation problem

    Hi, I have a problem while installing Adobe After Effects CS5.5 on my MacBook Pro running OS X 10.7. The installation stops after a couple of seconds and I receive the message: "Beta or prerelease versions of Adobe After Effects CS5.5 are installed o

  • Can not copy text from pdf with unicode font embedded.

    Hello, I have a pdf with unicode font embedded in it. The pdf has no restrictions. When i try to copy some text text fro m pdf and then paste itin word, the text is not the same which i copied from the pdf. it changes. I have tried multiple softwares

  • When I highlight objects, I'm able to move them with the arrow key but I can't drag them with my mouse.

    When I highlight objects, I'm able to move them with the arrow key but I can't drag them with my mouse.

  • PSE 8 or 9 Manual?

    I have PSE 8 which came with my camera.  There is no manual on the installation disk. There also appear to be no help files.  The download link via Help F1 appears to be a set of files for a Mac (anyway I can't seem to open them).  I can't use the on

  • Random tick sound from MacBook Pro (noticed it since updating to 10.6)

    Hi, I have the 2.4Ghz Unibody MacBook Pro 15" (Early 2009) with the removable battery. I went through a clean install of Snow Leopard, up to date with all the updates (10.6.1). Ever since I have been hearing random ticks. At first I thought it was th