KeyListener..for beginners..please help me

hi, im new to java..i think that this thing is simple to you guys..im trying to make a program where there is a ball bouncing around the screen..theres 3 walls one on the left one on the right and the other on top..there should be a moving catcher at the bottom..which should be controlled by the keyboard..
i already made the catcher..my only problem is..i dont know how to make it move..
by the way..i'm using threading..
it would be nice if you can post even a simple example of threading with keylistener even just left and right so i would know how to apply it..
i hope that someone there would help beginners like me, it would really be a big help..
thank you very much!
-dennis

Hi Madhuama, I'll try to give you a hand with this. First off, what OS is running on your notebook, what game are you attempting to play, and how is it not working? Is it not installing?
Thanks,
Fenian Frank
I work on behalf of HP

Similar Messages

  • URGENT FIX MY Connect Four game for Wednsday PLEASE HELP

    I am using an APPLET and i want to use JOptionpane it didnt work when i used it in the paint method. So i want to make a runner to make the program work. I don't know why the Graphics g = new Graphics isnt working PLEASE HELP. Email the revised code to my email at [email protected]. URGENT FOR TOMORROW PLEASE HELP. should i have a spearate class for the runner, just email me please if you can help.
    import javax.swing.JApplet;
    import java.applet.*;
    import java.awt.Graphics;
    import java.awt.Color;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JOptionPane;
    public class Board extends JApplet
    // the grid used for storing the game layout.
    private int[][] grid;
    // the player whose turn it is.
    private int currentPlayer;
    public final int player1=1;
    public final int player2=2;
    private int place1=5;
    private int place2=5;
    private int place3=5;
    private int place4=5;
    private int place5=5;
    private int place6=5;
    private int place7=5;
    public static void main()
    int column1;
    int column2;
    String name1;
    String name2;
    Graphics g=new Graphics();
    Board test= new Board();
    boolean wait=true;
    while(wait)
    String starts=JOptionPane.showInputDialog("Are you ready? \n (yes or no)");
    starts.toLowerCase();
    if(starts.equals("yes"))
    wait=false;
    name1=JOptionPane.showInputDialog("Enter Player 1's Name");
    name2 = JOptionPane.showInputDialog("Enter Player 2's Name");
    test.paintBoard(true,g);
    while(!test.done() || !test.hasWon(g,player1) || !test.hasWon(g,player2))
    column1=0;
    while(column1>0 && column1<8)
    column1=Integer.parseInt(JOptionPane.showInputDialog(name1+" what column do you choose?"));
    test.place(player1, column1,g);
    if(!test.done() || !test.hasWon(g,player1))
    column2=0;
    while(column2>0 && column2<8)
    column2=Integer.parseInt(JOptionPane.showInputDialog(name1+" what column do you choose?"));
    test.place(player2, column2,g);
    public Board()
    // create the grid
    grid = new int[7][6];
    // initialize the gridc
    for (int row=0; row<6; row++)
    for (int column=0; column<7; column++)
    // set the position to a default value
    grid[column][row] = 0;
    public boolean done()
    boolean flags =true;
    for (int row=0; row<6; row++)
    for (int column=0; column<7; column++)
    if(grid[column][row] == 0)
    flags=false;
    return flags;
    public void paint(Graphics g)
    public void paintBoard(boolean flag, Graphics g)
    int index= 0;
    g.setColor(Color.YELLOW);
    g.fillRect(0, 80, 700,700);
    g.setColor(Color.WHITE);
    //draws spaces
    for(int y =100; y<700; y=y+100)
    for(int x =10; x<700; x=x+100)
    if(flag==false)
    index++;
    if(index%2==0)
    g.setColor(Color.RED);
    else
    g.setColor(Color.BLACK);
    else
    g.setColor(Color.WHITE);
    g.fillOval(x,y,80,80);
    TextField column =new TextField(10);
    if(flag==false)
    g.setFont(new Font("Times New Roman", Font.BOLD,24));
    g.setColor(Color.YELLOW);
    g.drawString("C",45,245);
    g.drawString("O",145,245);
    g.drawString("N",245,245);
    g.drawString("N",345,245);
    g.drawString("E",445,245);
    g.drawString("C",545,245);
    g.drawString("T",645,245);
    g.drawString("F",145,145);
    g.drawString("U",145,345);
    g.drawString("R",145,445);
    g.setColor(Color.BLUE);
    g.drawString("START",512,548);
    public void paintFinish(Graphics g, int player)
    int index= 0;
    g.setColor(Color.YELLOW);
    g.fillRect(0, 80, 700,700);
    g.setColor(Color.WHITE);
    //draws spaces
    for(int y =100; y<700; y=y+100)
    for(int x =10; x<700; x=x+100)
    index++;
    if(player==1)
    g.setColor(Color.RED);
    else
    g.setColor(Color.BLACK);
    g.fillOval(x,y,80,80);
    public boolean hasWon(Graphics g, int player)
    boolean status = false;
    // check for a horizontal win
    for (int row=0; row<6; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row] &&
    grid[column][row] == grid[column+2][row] &&
    grid[column][row] == grid[column+3][row] &&
    grid[column][row] == player)
    status = true;
    // check for a vertical win
    for (int row=0; row<3; row++)
    for (int column=0; column<7; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column][row+1] &&
    grid[column][row] == grid[column][row+2] &&
    grid[column][row] == grid[column][row+3]&&
    grid[column][row] == player)
    status = true;
    // check for a diagonal win (positive slope)
    for (int row=0; row<3; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row+1] &&
    grid[column][row] == grid[column+2][row+2] &&
    grid[column][row] == grid[column+3][row+3]&&
    grid[column][row] == player)
    status = true;
    // check for a diagonal win (negative slope)
    for (int row=3; row<6; row++)
    for (int column=0; column<4; column++)
    if (grid[column][row] != 0 &&
    grid[column][row] == grid[column+1][row-1] &&
    grid[column][row] == grid[column+2][row-2] &&
    grid[column][row] == grid[column+3][row-3]&&
    grid[column][row] == player)
    status = true;
    if(status)
    paintFinish(g, player);
    return status;
    public void place(int player, int column, Graphics g)
    int index=0;
    if(column==1)
    index=place1;
    if(column==2)
    index=place2;
    if(column==3)
    index=place3;
    if(column==4)
    index=place4;
    if(column==5)
    index=place5;
    if(column==6)
    index=place6;
    if(column==7)
    index=place7;
    grid[column-1][index]=player;
    if(player==player1)
    g.setColor(Color.RED);
    if(player==player2)
    g.setColor(Color.BLACK);
    g.fillOval((column*100)+10,(index+1)*100,80,80);
    if(column==1)
    place1--;
    if(column==2)
    place2--;
    if(column==3)
    place3--;
    if(column==4)
    place4--;
    if(column==5)
    place5--;
    if(column==6)
    place6--;
    if(column==7)
    place7--;
    }

    gamefreak1192 wrote:
    I am using an APPLET and i want to use JOptionpane it didnt work when i used it in the paint method. So i want to make a runner to make the program work. I don't know why the Graphics g = new Graphics isnt working PLEASE HELP. Email the revised code to my email at [email protected] URGENT FOR TOMORROW PLEASE HELP. should i have a spearate class for the runner, just email me please if you can help.
    This is bloody ridiculous. You want somebody to do your work for you, you can't be bothered to carry on a discussion here and ask for private email, and you expect somebody else to make your urgency (i.e. lousy time management) their problem. You got big brass ones, kid.

  • I am using NIPCI6229 card i want to generate 5 V in the digital ouput line . it has to be there in the output line only for 100ms please help me

    i am using NIPCI6229 card i want to generate 5 V in the digital ouput line . it has to be there in the output line only for 100ms please help me. aftwer 100ms it has to go to zero state

    hi,
     You can try generating 5V continously for 100ms in a loop later on you can make it low.
    Hope this helps you.

  • HT201270 i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    capriz wrote:
    i have just updated my old 3GS ...
    To what... iOS 7 is Not supported on the 3 GS

  • My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetim

    My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetime doesn’t work neither does photo booth and now I cannot text people off my laptop unless they have iMessage.

    If you followed the instructions in the support article exactly (leaving the machine off for two minutes), then it has a hardware fault. Take it to an Apple Store or other authorized service provider for repair.

  • I'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    i'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    Hi Madhuama, I'll try to give you a hand with this. First off, what OS is running on your notebook, what game are you attempting to play, and how is it not working? Is it not installing?
    Thanks,
    Fenian Frank
    I work on behalf of HP

  • I cant save for web - please help me?!

    I cant save for web - please help me?!

    It says:
    "Could not complete this operation. An unknown operating system error has occurred."

  • I have a debit card but would like to download apps from the store. how do I do that? I can't possibly get a credit card just for this. please help.

    Hi,
    I have an iTouch. I'd like to download some free apps. but I have a debit card but would like to download apps from the store. how do I do that? I can't possibly get a credit card just for this. please help.

    I really do not think it is the iPad or your network connection. Other users have reported this very same issue. Try this and see if it works for you - it may not work - but it's easy to try - harmless - and it has worked in the past for others.
    Try signing out of your account and restart your iPad.
    Go to Settings>Store>Apple ID and tap the ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button. Go back to Settings>Store> Apple ID and sign in again.

  • I am not able to sign in with my exisiting Apple id, every time it is asking for review, please help me

    i am not able to sign in with my exisiting Apple id, every time it is asking for review, please help me

    Use this link to Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • I cannot see the Vidoe displayed on the screen, only hear the sound.  I am missing a component? Compressor, etc. I just downloaded the latest version of Quicktime for Microsoft, please help.

    I am not able to view my video taken with a memory card only the sound?  I am missing a component? Compressor, etc. I just downloaded the latest version of Quicktime for Microsoft, please help
    I can see it on Windows Media? Need help on this.

    It says SEDG 720X480 2:1 Mono.  Video came from Sd memory card taken with a Samsung Video Camera.
    Strangely enough, as a FourCC, SEDG is defined as "MPEG-4 hardware and software codec used in Samsung digital video products." Not a Windows or Samsung camcorder user but THIS WEB PAGE may be of some assistance.
    Also I will need to view a CD recorded by the same camera (DVD-RW) file extensions are VIDEO_RM.BUP
    VIDEO_TS.IFO, VIDEO_TS.VOB,  SAMSUNG.IFO  So far these files don't open even with Windows Media.
    I don't know what to do to be able to open up these files save them on my Hard drive and then be able to upload them to YouTube.  Any Ideas?
    IFO files tell how the video content is segmented and where the video data is located. BUP files contain back-up IFO information. VOB files contain actual multipled audio/video data. A DVD formatted to play in a commercial DVD player normally contains a series of files named "VTS##_#.VOB" where ## refers to the "title" series and "_#" (where # is not a zero) refers to the order in which the video title file data is played.
    Again, I am neither a Windows user nor an athority on Samsung VIDEO_RM folder structures. However, if your disc contains both a VIDEO_RM and VIDEO_TS folder, then I would normally assume the VIDEO_RM folder is present for legacy purposes and/or to provide information about the refording device while the VIDEO_TS folder actually contains the video object (VOB) file data. In any case, as I am not familiar with what software is available for muxed MPEG-2/AC3 editing/conversion on a Windows platform, I would try viewing the VOB files in an application like MPEG Streamclip (free). If you can play the Audio and video content (be sure to read the MPEG Streamclip requirements regarding codec installation), then you can edit (merge and/or trim) the raw data and convert it to a format compatible for YouTube uploading. (I.e., MPEG Streamclip is commonly used on the Mac for this type of work flow and the app is also available for Windows use.)

  • I try to make update for my iphone and start showing itunes need to be connected and never start and i connect my phone on itunes but it say need to be format for phone .please help me .

    I try to make update for my iphone and start showing itunes need to be connected and never start and i connect my phone on itunes but it say need to be format for phone .please help me .

    Hello Huss87bash,
    This screen indicates that the device is in recovery mode, and must be restored in iTunes before it can be used again.
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Once the device has been restored, you should be able to restore your device from a backup to replace all of your content and settings.
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/HT1766
    Cheers,
    Allen

  • SIR I NEED TO UNLOCK MY IPHONE 4 FOR FREE PLEASE HELP ME HOW I DO THIS...........

    SIR I NEED TO UNLOCK MY IPHONE 4 FOR FREE PLEASE HELP ME HOW I DO THIS..........

    Call your carrier and request it is generally the best idea.
    <Edited By Host>

  • Report should prompt me for parameters, please help.

    Hi All,
    I am using Crystal version 10, So is there any way I can get the behaviour of my parameters as dynamic parameter? I have this requirement because when I am deploying the Report on BO server, and try to open the report from InfoView, it is not prompting me for parameters, rather it is giving me the copy which we had scheduled earlier. To get the fresh data with different parameters, we again need to schedule the report.
    What I want is simple, Whenever user clicks on the report link in infoview, I should be promted for the parameters my report is using.
    Please help..
    Thanks
    -Azhar

    Hi
    It would prompt whenever it's refreshed.
    You can refer to Business View manager guide from [here|http://help.sap.com/businessobject/product_guides/boexir2/en/xir2_bv_admin_en.pdf ] for detailed information.
    Hope this helps!!
    Regards
    Sourashree

  • Best practices for ARM - please help!!!

    Hi all,
    Can you please help with any pointers / links to documents describing best practices for "who should be creating" the GRC request in below workflow of ARM in GRC 10.0??
    Create GRC request -> role approver -> risk manager -> security team
    options are : end user / Manager / Functional super users / security team.
    End user and manager not possible- we can not train so many people. Functional team is refusing since its a lot of work. Please help me with pointers to any best practices documents.
    Thanks!!!!

    In this case, I recommend proposing that the department managers create GRC Access Requests.  In order for the managers to comprehend the new process, you should create a separate "Role Catalog" that describes what abilities each role enables.  This Role Catalog needs to be taught to the department Managers, and they need to fully understand what tcodes and abilities are inside of each role.  From your workflow design, it looks like Role Owners should be brought into these workshops.
    You might consider a Role Catalog that the manager could filter on and make selections from.  For example, an AP manager could select "Accounts Payable" roles, and then choose from a smaller list of AP-related roles.  You could map business functions or tasks to specific technical roles.  The design flaw here, of course, is the way your technical roles have been designed.
    The point being, GRC AC 10 is not business-user friendly, so using an intuitive "Role Catalog" really helps the managers understand which technical roles they should be selecting in GRC ARs.  They can use this catalog to spit out a list of technical role names that they can then search for within the GRC Access Request.
    At all costs, avoid having end-users create ARs.  They usually select the wrong access, and the process then becomes very long and drawn out because the role owners or security stages need to mix and match the access after the fact.  You should choose a Requestor who has the highest chance of requesting the correct access.  This is usually the user's Manager, but you need to propose this solution in a way that won't scare off the manager - at the end of the day, they do NOT want to take on more work.
    If you are using SAP HR, then you can attempt HR Triggers for New User Access Requests, which automatically fill out and submit the GRC AR upon a specific HR action (New Hire, or Termination).  I do not recommend going down this path, however.  It is very confusing, time consuming, and difficult to integrate properly.
    Good luck!
    -Ken

  • PASSWORD FOR FLODERS  PLEAse  HELP URGENT

    HI ALL
    please tell me the method of implementing password
    provision for some folders/files in the system.
    it should ask for password authentification before
    opening when i click on the folder.
    please help urgent
    thanks
    belur

    Hi Swaroopba,
    It can be very well done thru Form based Authentication.
    For eg let me explain with respect to Tomcat.
    Go to
    $TOMCAT_HOME/webapps/examples/WEB-INF directory.
    Please add the following code in it.
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Protected Area </web-resource-name>
    <!-- Define the context URL's to be protected -->
    <url-pattern>/jsp/security/protected</url-pattern>
    </web-resource-collection>
    </security-constraint>
    Please add the following code in it. And you have to specify the roles for it.
    I hope this will be helpful for you.
    Or if you want it in an application, please let me know.
    Thanks
    Bakrudeen

  • Error: 'bobj' is undefined - crystal report for VS2013 - please help ASAP

    Currently we are trying to migrate from VS2008 to VS2013 and we installed Microsoft Visual Studio Ultimate 2013 on a windows 7 laptop. All our crystal report programs are migrated to VS2013. I downloaded Crystal report Support Pack 10 (v. 13.0.10.1385) executable version and installed it. Then opened our old project (from vs2008) in VS2013 and it went through the conversion process. Later I opened each .rpt file and saved in VS2013 so that the crystal report files will be saved in the new format.
    I am getting the Error: 'bobj' is undefined when I try to run the report. Am I using the correct service pack 10, or should I use service pack 9. I have read through all the posts related to this error in earlier version of VS. Is there any correct fixes for VS2013?
    This is urgent, I am stuck with this error. please help??? Thank you.
    JS

    Don,
    I followed Adil Siddiqui's Blog and it worked!!!!
    Add Following code to web.config file
    <configSections>
    <sectionGroup name=“businessObjects“>
    <sectionGroup name=“crystalReports“>
    <section name=“rptBuildProvider” type=“CrystalDecisions.Shared.RptBuildProviderHandler,
    CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral,PublicKeyToken=692fbea5521e1304,  Custom=null“ />
           <section name=“crystalReportViewer” type=“System.Configuration.NameValueSectionHandler“ />
    </sectionGroup>
    </sectionGroup>
    </configSections>
    <businessObjects>
    <crystalReports>
    <rptBuildProvider>
    <add embedRptInResource=“true“ />
    </rptBuildProvider>
    <crystalReportViewer>
    <add key=“ResourceUri” value=“~/crystalreportviewers13“ />
    </crystalReportViewer>
    </crystalReports>
    </businessObjects>
    NOTE: “<add key=“ResourceUri” value=“/crystalreportviewers13“ />” worked without the ~ sign.
    Click the link below for the complete post:
    Visual Studio 2012 Crystal Report not working on Windows Server 2012/ 0x800a1391 &amp;#8211; JavaScript runtime error: &…
    Thank you Don for your help.
    JS

Maybe you are looking for

  • Recipe Change report

    How do I track recipe changes. Is there a table/report that I can access to keep track of recipe changed by user, date and all changes made?

  • IPhoto won't import images from camera

    When I connect my camera to my computer iPhoto recognizes the camera but says there are no items to import. The camera has about 40 photos in its memory. What gives. I have intel iMac OS X 10.4.6, iphoto 6.0.1 and a nikon coolpix 5200 (lists says its

  • Email account

    Hi i have got some problem with Email account, when i open Email Account in Setup, only i see account activition and i bought this phone 3 days ago and i didnt enter any mail or got any activition password or some thing like this. my another problem:

  • *** ~ can this do this: i want to make multiple circles within circles like the target logo ~ ***

    im makign a simple visualisation. i want to dl a free trial of w/e i need and im done a link to a guide on how to do this would be good good links are good also need good sites to ask questions liek these in the future, thanks *** ~ can this do this:

  • HT5163 should i remove sim befor selling iphone3 ?

    shall i remove sim card from iphone3 before selling ?