KeyPressed program, can't get it to work

I am new to Java, still in the learning stages so a lot of things don't make sense to me. For example, why my code to make a ball move around the screen at the control of the keys won't work. I've tweaked it about 100 times now, so I figure I must be way off or something. Here is the code, so if anybody can let me know where I'm going wrong, I'd be very grateful.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Explore extends Applet implements KeyListener {
public int x = 175, y = 210, e;
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_A) {
x = x - 10;
if (e.getKeyCode() == KeyEvent.VK_D) {
x = x + 10;
if (e.getKeyCode() == KeyEvent.VK_S) {
y = y - 10;
if (e.getKeyCode() == KeyEvent.VK_W) {
y = y + 10;
repaint();
public void keyTyped(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_A) {
x = x - 10;
if (e.getKeyCode() == KeyEvent.VK_D) {
x = x + 10;
if (e.getKeyCode() == KeyEvent.VK_S) {
y = y - 10;
if (e.getKeyCode() == KeyEvent.VK_W) {
y = y + 10;
repaint();
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_A) {
x = x - 10;
if (e.getKeyCode() == KeyEvent.VK_D) {
x = x + 10;
if (e.getKeyCode() == KeyEvent.VK_S) {
y = y - 10;
if (e.getKeyCode() == KeyEvent.VK_W) {
y = y + 10;
repaint();
public void paint(Graphics g) {
Image background;
background  =  getImage( getCodeBase(), "Explore.gif" );
g.drawImage(background, 0, 0, this);
g.fillOval(x,y,15,15);

A component needs to have focus before it can receive events. By default panels don't receive focus. So maybe you need to add
panel.setFocusable(true), or
panel.requestFocus()
But your code doesn't show exactly what you are doing so its hard to give definite advice.

Similar Messages

  • I downloaded Photoshop cc trial, program opens, states program has a problem and closes right away. how can I get it to work?

    I downloaded Photoshop cc trial, program opens, states program has a problem and closes right away. how can I get it to work?
    I tried uninstalling and installing again same problem

    Moving this discussion to the Photoshop General Discussion forum.

  • Have entrourage and want to use Mail. Can't get it to work.

    I had a macbook and purchased the Microsoft office for Mac which included Entrourage.
    I have now purchased a new macbook Pro and want to begin to use Mail rather than Entrourage. 
    I have Entrourage on my new computer but i can't get it to transfer my information to the the Mail program
    I am on Charter.net at my office and sbcglobal.net at home.
    How can i get this to work.  I can receive on Mail, but i can't send.

    check your outgoing port settings and make sure it's using a specific port and not the default port, also you might want to check to see if it is using SSL, TLS or any other encryption.  Verify the setting from your old machine setup.

  • Trying to connect 2010 Mac mini to alba hd tv but can't get it to work, any theories?

    Trying to connect 2010 Mac mini to alba hd tv but can't get it to work, any theories?

    Welcome to the Apple Community.
    The iPad 1 is only able to do basic AirPlay, many providers of programming have blocked their apps from working with AirPlay.

  • How can i get hotmail to work in mail?

    So in hotmail it finally lets me select if I use POP to download Hotmail messages to another program, that program could make it so I can't read my messages on Hotmail. (For example, this might happen if you use Mac Mail or Mozilla Thunderbird).
    I have the "Do what my other program says-if it says to delete messages, then delete them." box selected.
    however my mail on my it mac says
    "There may be a problem with the mail server or network. Verify the settings for account “[email protected] ” or try again. The server returned the error: The connection to the server “pop” on port 110 timed out."
    yet it works on my itouch with mail and hotmail. what is going on? how can i get mail to work with hotmail on my mac?

    By doing a Google search for their phone number and their support website.

  • HT1203 i have tried this 6+ times to "How to share music between different accounts on a single computer" on my wifes mac and can not get it to work!! On my PC no problem but on the MAC it will not work, follow the instructions to the T but no go????

    i have tried this 6+ times to "How to share music between different accounts on a single computer" on my wifes mac and can not get it to work!! On my PC no problem but on the MAC it will not work, follow the instructions to the T but no go????

    It is almost as if the program does not exist on my computer. If I search for it, the only thing that comes up is the installer. I cannot find it anywhere despite the fact I have installed it numerous times, uninstalled it and conducted a fresh install, and the Adobe website checks says that it is installed.

  • Can't get Cisco to work on my Mac?

    I can not get Cisco to work on my Mac OSX 10.9.4
    I found this link on someone else's post about this same issue
    https://mega.co.nz/#!tlghxQoZ!I0VV1Th9pgiFMQagfG7LbHLvT8xT5uyKo8CrPAX5f9U
    Several people said that it worked for them but the last is in 2013 so I'm not sure if its older Mac OS systems
    I can down load and install fine but when I go to open it I get this error message
    ERROR! cannot write to Info.plist, there are permission problems, or you are on a read-only volume.
    This cannot run from within a read-only dmg file.
    But when I go to "get info" the program says i have "read and write" permission?
    I'm lost and new to Mac, can someone help me please?

    The Cisco VPN client is notoriously lousy. Use the built-in Cisco client if at all possible.

  • Can't get Java to work in IE 6!

    I downloaded and installed the file jre-1_5_0_01-windows-i586-p-iftw.exe and couldn't get java to work on websites that used it. So I tried to install it again and got the message "You already have this version of the JRE installed. Please uninstall the product through your add/remove programs utility before reinstalling." followed by "The Wizard was interrupted before J2SE Runtime Environment 5.0 Update 1 could be completely installed...".
    So I went into Control Panel --> Add or Remove Programs --> J2SE Runtime Environment 5.0 Update 1. I clicked to remove the program and eventually got the message "Fatal error during installation." Then I tried going into Control Panel and click the Java coffee mug icon. Nothing happened when I did that -- no Java console/panel or anything.
    So basically I can't get it to work and now I can't even remove it. In Internet Explorer --> Tools --> Internet Options --> Advanced I have the box checked beside Use JRE 1.5.0_01 for <applet> (requires restart). But when I go to Tools --> Sun Java Console, nothing happens.
    Can anyone help me out???

    Welcome to the wonderful world of Windows...
    In your user folder (c:\documents and settings\somewhere in there) you will find a java folder. Try removing that and then reinstalling the JRE through the java.com website.

  • Has anyone used reMIDI as a plug-in for GarageBand. I downloaded a trial version of reMIDI, which enables MIDI instruments to be strummed or arpegiated, but can't get it to work in Garageband.  How do I set it up?

    Has anyone used reMIDI as a plug-in for Garageband ('08)? The program allows MIDI instruments to be strummed or arpegiated. I have a trial version, but can't get it to work in Garageband. Wonder how to set it up.
    Thanks, Doctor Mark

    Port Forwarding.....or Port Mapping....as Apple calls it is a difficult and complex configuration method for most users. Because there are so many variables involved in this type of setup, it is not possible to provide a step by step guide that will work for everyone with all devices.
    It is possible that a setup guide exists for the the WD drive and AirPort Extreme, but you will have to go looking for it on the Internet. Even if you find one, it may not be tailored to your specific situation or needs.
    Sometimes, you can do everything right....at least according to someone's article or "how to" guide, and things still will not work correctly.
    In situations like this, when you really don't know what to do, you need to enlist the aid of an IT pro, who will know what to do based on your particular products and unique circumstances. Sometimes....they won't be able to get things working either due to particular circumstances.
    But, before you do this, I would strongly recommend that you use a Static IP address for your Internet connection with your ISP. If you do not have this now, contact them to ask them if they offer this type of connection. Expect to pay more for this type of service, of course.

  • Can't get iphoto to work after tampering with library in Finder

    I think I made a big mistake when I tampered with the iphoto library in Pictures in Finder.
    Now I can't get iphoto to work. All the pictures are gone in iphoto, the spaces are there but they are blank.
    When I open iphoto it goes into the mode (little spinning wheel appears) where I have to "force quit".
    Any supggestions on what I can do? Thanks.

    The list that shows is just data files and such.
    You can burn the entire iPhoto Library folder.
    You can burn each Year folder or any other variation.
    This is my workflow. The reason I do it the way I describe is because I want a backup of just the photos and video clips I take so I can copy them to a partition of my external drive and burn them to disc. On the other partition I backup my entire users folder
    When iPhoto 5 first came out I really think it was programmed to import the smaller 30 sec video clips that cameras were taking at the time. Since then, digital cameras, at least my Canon S2 can take clips as large as your memory card can hold. The first time I tried to download my images and movie clips with my new camera, iPhoto stalled at the movie clips. I wasn't going to take any chances messing up my iPhoto Library so I started using Image Capture to download all my images and Movie clips. I actually like doing it this way a lot better. My movie clips are downloaded into my Movies folder where I then put them in a dated folder.
    My photos are downloaded into my Pictures folder, where I then put them in a dated folder. I import the dated folder into iPhoto. I also keep all dated folders from photo downloads in the Pictures folder till I get enough Movie folders and Photo folders to fill a DVD. I burn them and then delete them from the hard drive.
    This way I have the photos in iPhoto and I also have just the photos backed up to DVD.
    The Movies I keep on the hard drive in their dated folders until I use all the clips for my iMovie projects for the Year. I then make sure they are all burned to DVD, then I delete those from my hard drive.
    Using Image Capture to download images and video clips:
    Open up Image Capture which is found in the Applications folder.
    When it is opened, go to Image Capture/Preferences
    Under the General button choose
    Camera: When a camera is connected, open Image Capture.
    The next time you connect your camera Image Capture will open.
    In the window that opens you will see an Options button. Click on that button to set your options.
    To find out more about Image Capture (it can do a lot more) Click on Help in the menu bar when Image Capture is open.
    iPhoto: How to Change the "Open Automatically" Preference
    If you find you can't change any of Image Captures preferences or can't access any drop down menus or they are greyed out, check to make sure Image Capture is loose in the Applications folder and not within a sub folder.
    Here is info on backing up your photos:
    Backing up your iPhoto Library
    1. Burn the iPhoto Library folder in the Finder to a CD or DVD
    This method will give you a burned iPhoto Library folder that can be copied back to your computer to replace a damaged library. You can also use this method to backup an old library when you want to create a new Library to use as your current library.
    insert a blank CD into your internal or external CD-RW drive and copy the iPhoto library to the CD icon on your desktop. When you drag the CD icon to the Trash/Eject button in the Dock, you are given the option to burn the CD. Click Burn and the CD is created. To burn a DVD backup of your digital images, use a DVD and a SuperDrive-equipped Mac
    The easiest way to burn an iPhoto Library folder in the Finder that is larger than 4.7 gig to fit on one DVD is to burn sections of the folder.
    Drag the iPhoto Library folder to the desktop
    Double click the folder to open it.
    Drag each Year folder to the desktop.
    You should be left with the iPhoto Library folder containing all the data files, and the Year folders.
    Combine whatever year folders that amount closest to a DVD burn size on one DVD. Make sure that you have burned all the Year folders, then the iPhoto Library folder with all the data files.
    If you ever need to use this backup, insert the DVDs into your computer and copy the folders to the desktop. Put all the Year folders back into the iPhoto Library folder. Then put the iPhoto Library folder back into the Pictures folder.
    You can also check out applications for disc spanning:
    Disc-spanning software
    DropDMG
    Toast
    Dragon Burn 4
    BackityMac
    Retrospect Express-comes with some external drives
    Retrospect for Macintosh Desktop Edition
    2. Copy the ENTIRE iPhoto Library to an external drive formated for a Mac. Do not use this as your only back up as the external can also go bad.
    3. Copy the ENTIRE iPhoto Library to your iPod in disk mode
    4.Creating your own CDs and DVDs for viewing in iPhoto
    This method is a great way to back up Albums of older photos or even your entire library if it is small enough to fit on a DVD. This method will give you a library that will mount within iPhoto in the source column to be viewed. To import any images from this library they need to be dragged into your library in the source column.
    If you just want to backup the images in your library:
    1) Within iPhoto select the images, albums or rolls you want to backup. Go to Share>Export and export them to a newly created folder on the desktop. Follow the directions in the next link.
    Creating a CD or DVD to be viewed in Windows or by a photo processing company
    1.. If you backed up the entire iPhoto Library by burning within iPhoto or burning the folder in the Finder, make sure the burned copy is a good working copy before you delete the iPhoto Library folder in the Finder. You delete the iPhoto Library in the finder by dragging it to the trash when iPhoto is closed. When you next launch iPhoto it will create a new empty library for you to start anew.
    2. If you burned just the images, be aware that that is all you are archiving. No metadata will travel with the images such as comments, keywords, etc.
    You can then delete those images within iPhoto by highlighting them and hitting the delete key, then empty iPhoto's trash. Do this often and in groups so iPhoto will not choke on too many images.

  • When I go into Libary in Encore CS6 there are nothing in it. How can I get it to Work?

    When I go into Libary in Encore CS6 there are nothing in it. How can I get it to Work?
    Operating System: Windows 7
    Has it ever worked? No If so, what's changed? : Nothing
    Recent System Hardware or Software change?: No

    Pasting the Content from the above link :
    Issue
    When you access the Library panel in Adobe Encore, the panel contains no content. Additionally, there is no subfolder named Library within the Adobe Encore application folder on your hard disk.
    When you access the title templates in Adobe Premiere Pro, the title templates are missing.
    When you access the template projects in After Effects, the template projects are missing.
    To the topSolution: Install the CS6 Functional Content
    Creative Cloud and disc product customersDownload and install the functional content for Adobe Premiere Pro and Encore.
    After Effects template projects were migrated to the After Effects Exchange.
    Adobe Premiere Pro and Encore Functional Content is available here:
    Mac OS (1.1 GB)
    Windows (734 MB)Installation instructionsMac OS
    Double-click the .dmg file to mount a disk image containing the installers.
    Choose to install Encore, or Adobe Premiere Pro functional content, or both packages. Open the folder for each package and locate the installer.
    Run "Install.app" to begin the installation process.
    After installing the first package of functional content, the installer ejects the disk image. Remount the disk image to run the second installer.
    Windows
    Note:If you installed the previous functional content packages, it's possible that you have Templates and Textures folders in the Program Files\Adobe\Adobe Premiere Pro CS6\Presets folder. Delete these folders before installing.
    Extract the contents of the downloaded zip file to a convenient location (for example, the Desktop).
    Run the .exe file to create install folders for the Encore and Adobe Premiere functional content installers.
    Navigate to the folder for the content you want to install and execute the installer.
    Electronic Software Delivery (ESD) customers only
    Download and install functional content for Encore, After Effects, and Adobe Premiere Pro. Note: Skip steps 1-6 if you have already downloaded functional content for Encore, After Effects, and Adobe Premiere Pro.
    In a web browser, go to www.adobe.com/membership.
    Sign in with your Adobe ID and password.
    Click View Order History.
    Look at the row with your order number and click Download.
    On the download page, look at the row with the description for function content. For example, for CS5, look for “Adobe Premiere Pro CS5: Download contains additional ReadMe files plus content (menus, buttons, and backgrounds) for Adobe Encore CS5.”
    Download this content using Akamai Download Manager or Alternate Download Method.
    Close Encore and Adobe Premiere Pro.
    (Mac OS) Double-click the .dmg file that you downloaded. On the Adobe Premiere Pro CS5 Content disk image, open the Encore Functional Content folder. Double-click Setup.
    (Windows) There are two files that you downloaded (for CS5, these files are PremierePro_5_Content_LS7.exe and PremierePro_5_Content_LS7.7z). Double-click the.exe file to extract the folders and files. Browse to the Encore functional content folder within the extracted folders. Double-click Setup. Following are detailed steps for Windows: 
    Go to the folder where you have downloaded files from the download page. For example, Desktop\Premiere. 
    Double-click PremierePro_5_Content_LS7.exe. The installation files are extracted to a folder named Adobe CS5. For example, Desktop\Adobe CS5.
    Go to the Adobe CS5\Premiere Pro Family Content Installers\Adobe Encore CS5 Functional Content folder.
    Double-click Set-up.exe. Installation starts. Follow the instructions to complete installation.
    To the topAdditional solution: Install the Resource Central library content
    Download the extra library content
    Choose your language to begin the download:
    English French German Japanese Italian Spanish Korean
    Extract the Library content to the Library folder
    Extract the zip file that you just downloaded to create a .7z file (for example, en-US.7z).
    Extract the .7z file to any convenient location (for example, the Desktop). This step creates a folder based on the language you selected.
    7-zip for Windows (available for download at http://www.7-zip.org/download.html)
    The Unarchiver for Mac OS (available for download at http://wakaba.c3.cx/s/apps/unarchiver.html)
    Copy the contents of the language folder (for example, en-US) to the following location:Windows: C:/Program Files/Adobe/Adobe Encore CS6/
    Mac OS: Applications/Adobe Encore CS6/
    If you choose a custom Library folder location other than the default location, launch Adobe Encore and browse to your custom Library folder location.Windows: Edit > Preferences > MediaMac OS: Encore > Preferences > Media

  • When i tried to download iOS8 on my iPad Mini it told me that I needed to connect my iPad to iTunes, I have done that and now it says I need to restore my iPad. How can I get my iPad working without losing everything on my iPad?

    When i tried to download iOS8 on my iPad Mini it told me that I needed to connect my iPad to iTunes, I have done that and now it says I need to restore my iPad. How can I get my iPad working without losing everything on my iPad? I don't want to lose my apps and photos!
    Help would be much appreciated!

    If you are getting the connect to iTunes screen then it's too late to take a new backup and/or copy anything off it. Prior to starting the update did you take a backup, either to the cloud and/or to your computer's iTunes ? If not then have you recently taken a backup that might have your photos and apps content/settings in it ?
    As long as the apps are still in your country's store then you should be able to redownload them via the Purchased tab in the App Store app (and the Purchased link under Quick Links on the right-hand side of the iTunes store homepage on your computer's iTunes), and if the apps store their content on a server/cloud service then you might be able to get their content back from that - if they store their content on the device then you will need to have a backup.
    For our photos you could try doing a search for programs that claim to be able to recover content from a device - I haven't used any so I can't suggest one.

  • HP Pavilion dv7-2075eo Entertainment notebook pc - Can´t, get TV tuner working

    HD went down, and after I made a recovery, I opgrated to Windows 8.(32 bit)
    All driver for hardware were lost.
    I´d found all drivers on HP´s site, but I can´t, get TV tuner working - can´t find hardware-
    Can enybody help me with that?

    I am going to be honest here. There is a good chance that not all hardware will be functional. This system was not designed for Windows 8 and was long before Windows 8.
    With that being said, you can try this Vista Driver in compatibility mode. This is the driver for the express TV Tuner Card.
    1. Download the driver.
    2. Start the extraction process and take note of where it is getting extracted to. Cancel the installation once the extraction is finished.
    3. Navigate to this extracted folder. Right-click the setup/installer file and select Troulbeshoot Compatibility.
    4. Follow the prompts in the troubleshoot and select the automatic settings option.
    5. Select Test Program when prompted.
    6. Follow the installation.
    7. If no errors were presented, it may work at this point.
    NOTE: This process may not work, but it is a good place to start.
    If you were using Windows Media Center previously, you may need to find a different solution. It is not available by default and will need to be added separately to Windows 8.
    Here is the link for Media Center for Windows 8. It starts off by adding it to Windows 8 Pro, but the actual wording of the special offer towards the bottom does not specify Windows 8 Pro as a requirement. It may be worth trying.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Trying to activate newly installed Acrobat 11 but can't access internet thru program - can otherwise get online with no probs

    trying to activate newly installed Acrobat 11 but can't access internet thru program - can otherwise get online with no probs. any suggestions?

    Hey Marina Hannwacker,
    I would recommend you to Refer this link - Offline Activation and let me know if it works for you.
    Regards,
    Rahul Tyagi

  • Got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?

    got my password wrong twice and my mini is disable. I connected to iTunes, but can't get it to work. Can some one guide my through?

    If it's showing the red disabled screen due to incorrect passcodes then you may need to put the iPad into recovery mode : http://support.apple.com/kb/ht1808 - you should then be able to reset the iPad via your computer's iTunes and restore/resync your content to it

Maybe you are looking for

  • Firefox will not open because of a "nssutil3.dll" error. How can I back up my bookmarks when Firefox will not open?

    Firefox would not open because of a "nssutil3.dll " problem. I've researched the problem, and I am using Norton 360 which is not a known antivirus program that deletes the file as a trojan. I want to uninstall and reinstall firefox, but first I want

  • Itunes download problem-Lenovo E545 running Windows 7itunes download problem-Lenovo E545-Windows 7

    Just bought a new Lenovo E545, It runs Windows 7 (2009). I am trying to download itunes and recieved a mesage After clicking "ok" the whole download process went "rolling back." The download then happens all ove again until another message comes up:

  • Messages reverts to iMessage instead of MMS

    I used to have an iPhone and switched back to Android this past year. In group messages and only group messages, friends and family who still do have iPhones will text me but it randomly sends as an iMessgae instead of a normal mms. My phone number i

  • How to use a digital booklet?

    I'm using iTunes v8. I've downloaded a few ditigal booklets, but cannot seem to do anything with them. When I try to open one, Adobe Reader opens with an error message "invalid path." I cannot view them on my iPod Classic either. I asked Apple Suppor

  • Use SWF to play another SWF

    I've been looking over the net for a while and couldn't find the answer, so I figured I would try here.  I'm designing a website, where there is a swf file on the right, and a swf file on the left. I want the one on the left to be able to communicate