Results 1 to 3 of 3
  1. #1
    Bibendum is offline Member
    Join Date
    Oct 2007
    Posts
    7
    Rep Power
    0

    Default Help with keyboard events?

    I've been programming for a short while, and I just started learning java. Right now, I'm making a Galaga-like game, just to see if I could.

    Here's a link to the source.

    Everything is working fine, except for the keyboard events, and I have no idea what I'm doing wrong. Also, if I made any mistakes with the basic structure and such, help with that would be appreciated.

    -Joe

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    public SpaceGame(int width, int height){
        ...
        addKeyListener(new MyKeyListener());
        // Keyboard input requires the listening component to have the focus.
        setFocusable(true);
        new Thread(this).start();
        ...
    public static void main(String [] args){
        ...
        frame.add(g);
        // This should be last for proper/complete initialization.
        frame.setVisible(true);

  3. #3
    Bibendum is offline Member
    Join Date
    Oct 2007
    Posts
    7
    Rep Power
    0

Similar Threads

  1. How to get the Call events in J2ME
    By krmlkr in forum CLDC and MIDP
    Replies: 1
    Last Post: 03-08-2008, 09:39 AM
  2. Need Help With Button Events
    By adlb1300 in forum New To Java
    Replies: 5
    Last Post: 11-03-2007, 05:36 AM
  3. To capture events with struts
    By Ed in forum Web Frameworks
    Replies: 2
    Last Post: 07-04-2007, 06:01 AM
  4. Help, events in Jbutton class
    By Heather in forum Java Applets
    Replies: 2
    Last Post: 06-30-2007, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •