Search:

Type: Posts; User: Fermen

Search: Search took 0.17 seconds.

  1. Replies
    8
    Views
    2,426

    [SOLVED] Re: KeyListener won't listen

    Yeah, :D I made it work!


    if(e.getKeyCode() == 38)
    {
    y = player1.getY();
    System.out.println("Pressed");
    // y = 200;
    ...
  2. Replies
    8
    Views
    2,426

    [SOLVED] Re: KeyListener won't listen

    Because the Y value is the components Y - value. When I change the Y value
    int y = 100; the component is changing it's position. Then I just thought it sounded reasonable that it would also change...
  3. Replies
    8
    Views
    2,426

    [SOLVED] Re: KeyListener won't listen

    Because I change the value of y:
    y = y + 10;

    Or?? wouldn't that work?
  4. Replies
    8
    Views
    2,426

    [SOLVED] Re: KeyListener won't listen

    I tried using the .setFocusable(true) in "public Spelplan". I also kept the printline "Pressed" inside the if-statement. Now it says "Pressed", but the component does not move.
  5. Replies
    8
    Views
    2,426

    [SOLVED] KeyListener won't listen

    Why won't my "player1" move???
    Class with main


    import java.awt.Color;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
Results 1 to 5 of 5