Re: KeyListener not working



Justin wrote:
I'm just messing around, getting ready to write a game for fun and
can't get this KeyListener to work. ...

See below.

package javaapplication1;

import javax.swing.JPanel;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;

public class Board extends JPanel implements KeyListener{

private final int BOARD_WIDTH = 12;
private final int BOARD_HEIGHT = 20;
private final int BLOCK_SIZE = 10;
//private Piece pieceBoard[][] = new Piece[BOARD_WIDTH]
[BOARD_HEIGHT];

public Board() {
setPreferredSize(new java.awt.Dimension(BOARD_WIDTH *
BLOCK_SIZE, BOARD_HEIGHT * BLOCK_SIZE));
setSize(getPreferredSize());
setBackground(java.awt.Color.WHITE);
setLayout(null);

setFocusable(true);
...

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200712/1

.



Relevant Pages

  • KeyListener not working
    ... public class Board extends JPanel implements KeyListener{ ... private final int BOARD_HEIGHT = 20; ... public void keyPressed{ ...
    (comp.lang.java.help)
  • poker odds
    ... public static final int HIGH_CARD = 0; ... private static Logger logger; ... public Poker(int numCard, Card deck) ... public void maxSimulation ...
    (comp.lang.java.programmer)
  • problem with vmr9 image compositor - method Draw
    ... I play video with playlist, if i play video about 5x it is ... but so 6round of video playing throw exception int ... private void ConfigureVMR9InWindowlessMode() ... Surface renderTarget = new Surface; ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: using ref keyword performance
    ... // private fields... ... int valueCount = values.Length; ... static void TestWithRefLoop() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: The code for "sorting in C sharp considered superior" in five parts for easier download
    ... private bool interchangeSortTest() ... ("Sequence error after interchange sort", ... private bool labelHasFontTag ... int intGridTop, ...
    (comp.programming)