How to get the arrow keys to work in 2D game?

I am designing a 2D game (Applet) in which the objective is to move a dot from one end of the room to the other.
how do i get the dot to move in all 4 directions, please help.
If you may, please mention a few EXCEPTIONAL tutorials on JAVA game design.

The best (?) way is to use a KeyListener. http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/KeyEvent.html
In the class that you want the keyevent to occur, put this in your class declaration implements KeyListener { Then somewhere in that class, put addkeyListener(this);. You need to have three methods in this class - keyTyped(KeyEvent e), keyPressed(KeyEvent e) and keyReleased(KeyEvent e).
Here's a sample.
public class Example extends JFrame implements KeyListener
     //some code goes here...
     public void keyTyped (KeyEvent event) {}
     public void keyReleased (KeyEvent event) {}
     public void keyPressed (KeyEvent event)
          int key = event.getSource();
          if (key == KeyEvent.VK_UP)
          //etc.
}

Similar Messages

  • How do I get the arrow keys to move one character at a time in the address bar or search box?

    I can no longer get the arrow keys to advance or retard "one character at a time" in the address bar, the search box, or on any form in Firefox. This feature works in other browsers without a problem. The "Home" and "End" keys do not work either. How do I fix this behavior?

    How do I configure the AX to connect to the hub's wireless network? It will only scan one base station Airport Express at a time in the Airport Utility. I think what I am trying to do is use the hub as a router to the two AX's. Is there a specific way to set this up?
    To set up the AX to join a wireless network as a "Wireless Client," using the AirPort Utility, either connect to the AX's wireless network or temporarily connect your computer directly (using an Ethernet cable) to the Ethernet port of the AX, and then, try these settings:
    Launch the AirPort Utility.
    Select the AX.
    If not already connected to the AX's wireless network, go ahead and switch to it when prompted.
    AirPort Utility > Select the AX > Manual Setup > AirPort > Wireless
    Wireless Mode: Join a wireless network
    Network Name: <type in the network name/SSID of the wireless network that you want to join or select it from the pop-up menu>
    Wireless Security: None OR, if you are using security on your wireless network:
    Wireless Security: <Select the appropriate level of security for the existing wireless network: WPA/WPA2 Personal | WPA2 Personal>
    Password: <enter your wireless network security password>
    Verify Password: <re-enter the same security password>
    Click Update to write the new settings to the AX.

  • I cannot get the numerical keys to work on my Mac pro any ideas?

    HI
    I am trying to return something bought on line and need to fill out various information on the website. I cannot get the numerical keys to work anybody any ideas as to what I may be doing wrong?
    GL

    Hi Goostrey Lou,
    Thanks for visiting Apple Support Communities.
    Start with the tips in this article if some keys on your keyboard are not working:
    One or more keys on the keyboard do not respond
    http://support.apple.com/kb/ts1381
    All the best,
    Jeremy

  • I create a mobile game. How to get the signing key?

    I create a mobile game. How to get the signing key? Is the certificate is payable? Sorry if the topic is in the wrong section.

    You need to be an iOS/Mac OS X developer.
    https://developer.apple.com/devcenter/

  • How to get the Primary key from  Synonym

    Hi ,
    I want to get the Primary Keys for my tables . I used
    java.sql.DatabaseMetaData databasemetadata = connection.getMetaData();
        ResultSet rs = databasemetadata.getTables(null, null, "%", null);
    rs.next();
        System.out.println(" TABLE_CAT "+ rs.getString(1));
        System.out.println(" TABLE_SCHEM  "+rs.getString(2));
        System.out.println(" TABLE_NAME "+rs.getString(3));
        System.out.println(" TABLE_TYPE  "+rs.getString(4));
        System.out.println(" REMARKS "+rs.getString(5)); gives :
    TABLE_CAT null
    TABLE_SCHEM PROGRESS
    TABLE_NAME ApplicConv
    TABLE_TYPE SYNONYM
    REMARKS null
    Now if I use :
      rs = databasemetadata.getPrimaryKeys(null,"PROGRESS","Applicconv");
      System.out.println("Is result set Non empty "+rs.next()); gives :
    Is ResultSet non empty false .
    Can you tell me why this result is empty? Is it because of my table is a Synonym?
    If it is Synonym how to get the primary key ?

    You can use DatabaseMetaData#getPrimaryKeys.

  • Arrow keys dont work on flash games

    Hi, anyone had this problem? The arrow keys dont work when I
    play flash games. Have downloaded latest version of flash (multiple
    times) and still the same problem. I load up a flash game, then can
    only use the mouse to play. Arrow keys just dont respond when used.
    Arrow keys work fine on other programs, just flash is a
    problem
    Really hope someone has had this before and knows what to do.
    Thanks for any replies.

    I had the same problem and was looking around on the net for
    help. I found a post that said to try using the numbered keypad
    instead, as in 8 is up, 2 is down, 4 is left and 6 is right. It
    worked for me so hopefully this will help you as well. :)

  • How to get the past top 100 match data of game app?

    how to get the past top 100 match data of game app?

    What game app? Have you contacted the developer of the app?

  • How to get the PRIMARY KEY of a table at runtime ???

    Hi everybody,
    My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
    So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
    Any suggestions will be appreciated..
    Thanks,
    Sekhar

    U will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
    pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
    Or else you can try with 'DDIF_TABT_GET'
    Or try this code
    PARAMETERS: p_table TYPE tabname OBLIGATORY.
    DATA: go_strucdescr   TYPE REF TO cl_abap_structdescr,
          gt_tab_fields   TYPE ddfields.
    FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
    TRY .
    *   Get the details of the DDIC table
        go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
      CATCH cx_sy_move_cast_error .
        MESSAGE 'Error while casting' TYPE 'S'. RETURN.
    ENDTRY.
    * Check if input is a DDIC table
    CHECK go_strucdescr->is_ddic_type( ) = 'X'.
    * Get the details of the table fields
    gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
    * Display the Key fields of the table
    LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
      WRITE: / <gwa_tab_field>-fieldname.
    ENDLOOP.

  • How to get the UDDI Key to publish a service provider system in SR?

    Hi,
    I am following instruction in appendix 1 & 2 of the white paper at https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1079b1af-dcb7-2b10-9ebb-eafcaa3cbbea?overridelayout=true
    trying to publish a service provider system into the service registry. One thing not clear to me is how to get the uddikey as needed in step 6 in appendix 1.
    My service registry is in a PI 7.1 SP4 system. I followed the instruction in appendix 2 but there is no uddi key displayed in the General tab. Please help.
    Regards,
    Jiannan
    Paragraph extracted from the whitepaper:
    There may be cases in which the NWA logical settings do not match the Services Repository
    settings when Visual Composer is trying to locate the enterprise services. Such cases can occur
    when there is no SLD ID definition of the physical system in the Services Repository.
    Currently, Visual Composer cannot search for services on a physical system with an empty SLD ID
    (which is not a valid one).
    To obtain this capability, the following steps should be performed to generate the necessary data
    for each system with a non-valid SLD ID, so that Visual Composer can search for services over it.
    1.Log on to http://<serverName>:<serverPort>/WSNavigator.
    2.Select the Services Registry radio button.
    3.In the Find field, enter sr and choose Go.
    4.Select the ServicesRegistrySi line and choose Next.
    5.Under the Operation Name, search for the publishPhysicalSystems operation, select it and choose Next.
    6.Fill the service information parameters with the following (see Appendix 2 for details on how to get this information) :
      6.1.Click the + icon in the physical system[].
      6.2.Deselect the Classifications checkbox.
      6.3.Click the + icon in the classificationReferenceGroups[].
      6.4.Click the + icon in the classificationReferences[].
      6.5.Deselect the classificationSystemKey checkbox.
      6.6.Deselect the uddiKey checkbox and enter the value <localUddiKey>.
      6.7.Deselect the value checkbox and enter the value <localSystemHostName>.
      6.8.Deselect the host checkbox and enter the value <localHostName>.
      6.9.Deselect the physicalSystemKey checkbox.
      6.10.Deselect the logical key checkbox and enter the value <System name>.<SystemHome>.<host name>.
      6.11.Deselect the systemName checkbox and enter the value <system name>.
      6.12.Deselect the type checkbox and enter the value 2.

    Hi Jiannan,
    No worries, you can go to UDDI client from the main page of PI  i.e. http://<serverName>:<serverPort>/
    And you use the search function for  the TModel for your Physical System. Search parameters can use the % wildcard.
    Hit the search and you find the UDDI Key for the Physical System.
    Cheers.
    Hemant Chahal

  • How to get the garbage collector to work?

    Hi,
    i have i program where i load an image scale it down and save the scaled version in an array. I do this for a whole directory of images.
    After every image i set the temporary variable for the loaded image = null and call the function System.gc().
    My problem is, that the garbage collector does�nt give the memory of the loaded image free and the used memory of my program grows with every loaded image.
    /* Reads all images from a folder an stores them in an Array of images */
         public static BufferedImage[] readScaledImagesFromFolder(String folder,
                   int maxSize) {
              File dir = new File(folder);     /* Open the Folder */
              String[] children = dir.list();          /* Get the children of the folder */
              if (children == null) {
                 // Either dir does not exist or is not a directory
                  System.out.println("No images in the folder!");
                  return null;
             } else {
                  /* Init array for images */
                  BufferedImage[] images = new BufferedImage[children.length];     
                  int i = 0;
                  int index = 0;
                  BufferedImage temp;
                  String filename, fileending;
                 for (i=0; i<children.length; i++) {
                      // Get filename of file or directory
                     filename = children;
         /* Get the fileending of the file */
         fileending = filename.toLowerCase().substring(filename.length()-4);
         if(fileending.equals(".jpg") || fileending.equals(".bmp")
                   || fileending.equals(".png") || fileending.equals(".gif"))
              /* Read the image */
              temp = util.ImageUtils.loadBufferedImage(folder+"/"+filename);
              /* Scale the image down and save it in an array */
              images[index] = Util.getScaledImage(temp,maxSize);
              index++;          
         temp = null;
         System.gc();
         Mosaic.sourceImageNum = index;
         System.out.println((index+1)+" resized pictures loaded from folder: "+folder);
         return images;     
    How can i get the gargabe collector to work after every iteration?
    I tried to let the Thread.sleep(10) after System.gc() but it does�nt help.
    Thank you every much
    JackNeil

    Hm yes.. i now that System.gc() is only a
    suggestion.
    But i know what my program is doing and that it
    does�nt need the temporary image anymore after i have
    a scaled down version. And the temporay image will become unreachable as soon as reading the next one overwrites your temp variable. Setting the variable to null doesn't have much effect.
    It would be smarter to load the new image over the
    old temporary image and not to expand the heapsize to
    maximum.Then look at the possibitly of loading the next image into the same bufferedimage.

  • Help!! I can't find how to get the enter key......

    Hi...
    I am information technology student. I am now first year second semester
    I need help because I don't know how to catch the enter key in JTextField.
    I want to submit the form when user press the enter key in JTextField....
    I only can find KeyEvent.VK_ENTER ( actually that is not what I want)
    Another thing is
    "How to add a JMenuItem into a JMenuItem...."
    I want to do like this.... When you click the "Tools bar" in View item.. another menu comes out...???"
    He he... I hope you all can understand what I mean.. because I know my english is not so good... because I am from Myanmar.
    for(int i=0;i<1;i--)
    System.out.println("Thanks A lot");
    Thu Rein Nyo...
    You also can reply by e-mail.. thanks

    Hi...
    I am information technology student. I am now first
    year second semester
    I need help because I don't know how to catch the
    enter key in JTextField.it can be done easily by adding an actionListener to the JTextField. So when u enter something in the field and press enter the event will be caught and the code which u write in that will get executed.
    Eg:
    JTextField.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    Your code comes here.
    Another thing is
    "How to add a JMenuItem into a JMenuItem...."
    I want to do like this.... When you click the "Tools
    bar" in View item.. another menu comes out...???"I think you are gettin confused with JMenu and JMenuItem. What u need to do is create a JMenu add another JMenu to it and add JMenuItems to it.. and ur problem will be solved.
    He he... I hope you all can understand what I mean..
    because I know my english is not so good... because I
    am from Myanmar.
    for(int i=0;i<1;i--)
    System.out.println("Thanks A lot");
    Thu Rein Nyo...
    You also can reply by e-mail.. thanks

  • How to get the Wiki search functionality working?

    hi,
    Another Wiki question regarding the 7.1u1 Portal wiki functionality: What is necessary to get the wiki search functionality working? Right now when using the wiki search page all it does is return to the search form, no errors but no hits either. I guess some additional administrative work is needed to get search working?
    thanks, tom

    haven't touched anything except for the wiki template jsps to change the design. it is a linux rh4 install. there are no communities on that server (yet), just the wiki portlet in a tab so far. is the wiki search dependent on the portal search server or totally separate (ie self contained wiki search)? any additional services or such that need to be started for it to work?

  • How can I get the escape key to work again?

    I've used "esc" to get out of VI's insert mode for 40 years. I am not going to relearn that keystroke as "ctl-esc", period. Even if I were to do that, then I'd be typing ctl-esc on other platforms where it would not work because I have to type "esc" alone. If there is a way to fix in in System Preferences->keyboard, I cannot find it. If there is not, then it is completely 100% brain-dead wrong. I hope that's not the case.  So there is definitely a bug:
    The key-up event on the escape key does not cause the escape key code to be delivered to the active window when no other key is pressed, or
    The UI is sufficiently obtuse that the cause of the suppression cannot readily be found.
    I do hope it is merely the latter because I am compelled to use Outlook and Outlook does not work properly under OS/X 10.6.  (Our Exchange Server is rigged to only allow Outlook clients to send email outside of the company.)
    Thank you.

    The answer is:  The bug is in the UI.  Speech recognition was enabled, by default it uses the bare escape key as a "mic on" indicator, and it does not leave any trace in the keybord configuration.  So that is the bug.  It needs to leave a trace there, a la: "X Listen-for-voice-command  ^" under Mission Control.

  • How do I get the esc key to work without having to use shift esc?

    Just got a new iMac and migrated everything from my old iMac but one thing is not working. I use to be able to use the esc key to back out of full screen mode or deselect items. It only works now if I use shift and esc. I would like to set it so I can just hiy esc and not shift esc.
    Any help woul dbe appreciated.
    Jeff

    Maybe some third party software interference.  Try a guest account or SafeBoot to diagnose.
    different app behave differently, for ex Firefox: command-shift-F

  • On OS X Lion Mountain, how can I get the escape key to work?

    While typing i accidentally disabled the f keys (f1-f10) on the first row and the esc key. After trying to find a solution i manage to enable he f keys but works only after typing the fn key with an f key. The esc key still doesnt work. Can someone helpe me

    Disable the feature in System Preferences.
    http://support.apple.com/kb/HT3399

Maybe you are looking for

  • Switched iPod Video format from PC to Mac - "Restore" fried my iPod

    I bought an iPod Video 30gb in Dec. 05. I originally formatted it to work with my Dell PC Inspiron laptop. Everthing worked great and I didn't have any problems. About two months ago I bought a Macbook and transferred all of my files, including my mu

  • WORKING example of BlazeDS with Flex 3 and FlexBuilder

    Can someone point me to an actual working example with BlazeDS used with Flex 3 and Eclipse? The examples on livedocs are broken or imcomplete. Others work to varying degrees but fail at some point. What I'd like to see is the following: 1. How to cr

  • RE: Sync stopped

    Hi I receive the error every time the databases trys to sync. Sync failed with the exception "We have encountered an issue in syncing your data."    For more information, provide tracing ID '1b1f3835-7fed-4d08-abb5-2323782b849e' to customer support.

  • Problem with document going back into credit check

    Hi Gurus, I have a scenario where the document that is released from credit check is coming back into credit check before the stipulated time. Further information: 1. OVA8 for the particular credit control area and risk category has the settings as f

  • Different PR number range

    Dear all At my client there are two scenarios of PR creation from maintenance order : one is for planned services against outline agreement in which PM user will create PO itself. another is PM user will create PR thru maint. order and give it to com