Results 1 to 2 of 2
- 04-20-2010, 07:18 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
How To Use Key Binding or Key Listener to move object
I'm creating a pong game and I need help moving the boards.
I have posted the codes for one of the boards.
Java Code:private class PlayerOne extends Thread implements KeyListener { int width = gameBoard.getWidth(); public void run() { while (true) { paintPaddle(); doNothing(PAUSE); setFocusable(true); addKeyListener(this); } } public void paintPaddle() { Graphics g = firstPlayerSpace.getGraphics(); g.setColor(Color.RED); g.fillRect(1, 180, 5, (width / 12)); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { throw new UnsupportedOperationException("Not supported yet."); } public void keyReleased(KeyEvent e) { throw new UnsupportedOperationException("Not supported yet."); } }
-
Duplicate thread of this one: Help Using KeyListener to Move an Object
Please let's avoid splitting the discussion of this problem in multiple threads.
Locked.
Similar Threads
-
Help Using KeyListener to Move an Object
By jjonesmu in forum New To JavaReplies: 3Last Post: 04-20-2010, 10:35 PM -
Mouse Listener for mouse floating over object?
By Krooger in forum AWT / SwingReplies: 1Last Post: 11-18-2009, 04:34 AM -
[SOLVED] Key binding Q
By playwin2 in forum New To JavaReplies: 3Last Post: 11-04-2008, 06:04 AM -
Spring binding in jsp
By Pierre Javason in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-05-2008, 12:21 PM -
Adding listener to non-Java object?
By cruxblack in forum Advanced JavaReplies: 5Last Post: 07-30-2007, 02:19 AM


LinkBack URL
About LinkBacks

Bookmarks