473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating Key Listeners for JAVA

Hi Everyone,

I have created a Java Applet that creates shapes, but I need help
with code to make them move Left, Right, Up, and down. I am using a
IDE called NetBeans, and created a "formKeyPress" to help with the
movement on the applet form area. However, I have no idea what code to
use. This is how the "formKeyPress" looks like:

private void formKeyPressed(java.awt.event.KeyEvent evt) {
}

Can anyone help me? Please, please please....
Rafael
Jul 17 '05 #1
2 5356
sp***@rloteck.com (Rafael) wrote in message news:<a5**************************@posting.google. com>...
Hi Everyone,

I have created a Java Applet that creates shapes, but I need help
with code to make them move Left, Right, Up, and down. I am using a
IDE called NetBeans, and created a "formKeyPress" to help with the
movement on the applet form area. However, I have no idea what code to
use. This is how the "formKeyPress" looks like:

private void formKeyPressed(java.awt.event.KeyEvent evt) {
}

Can anyone help me? Please, please please....
Rafael


public class MyApplet extends Applet implements KeyListener{

public void init(){
...
...
addKeyListener(this);
...
...
}

...
...
public void keyPressed(KeyEvent e){
//See KeyEvent javadoc.
//If the key is VK_LEFT move the shape to the left, etc.
//Change the parameters and call repaint()
}
...
...
}
Jul 17 '05 #2


"Rafael" <sp***@rloteck.com> wrote in message
news:a5**************************@posting.google.c om...
Hi Everyone,

I have created a Java Applet that creates shapes, but I need help
with code to make them move Left, Right, Up, and down. I am using a
IDE called NetBeans, and created a "formKeyPress" to help with the
movement on the applet form area. However, I have no idea what code to
use. This is how the "formKeyPress" looks like:

private void formKeyPressed(java.awt.event.KeyEvent evt) {
}

Can anyone help me? Please, please please....
Rafael


JAVA [sic] is not an acronym, Java is a programming language.

You shouldn't using NetBeans if you don't understand the fundamentals of the
language.
I suggest you read up on interfaces.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
(2003 VTR1000F)
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hal Vaughan | last post by:
I've said here before that I'm self taught. I have 4 reference books, and they mention listeners and give partial examples, but not one gives me a good, clear example of setting up a listener,...
2
by: Jon | last post by:
Hi, im trying to create an interface, which has a button and 2 radio buttons, which affect text which is outputted to a text area when the button is pressed. The button works on its own, but I can...
1
by: Fred Mellender | last post by:
When I code: Debug.Assert(false, "this is a message"); it works fine, and out comes the dialog box. When I code Trace.Listeners.Clear(); Debug.Assert(false, "this is a message"); No message...
2
by: Michael Powe | last post by:
Hello, Is there a way (in JS) to detect listeners on an element and identify them? The purpose would be to selectively attach additional listeners if certain conditions are met. For example, I...
13
by: Tony | last post by:
And that is probably very unclear - so let me explain. Please forgive me if I screw up the terminology (and let me know what the correct term would be): What I want to do is to create a library...
3
by: Absolon | last post by:
Hi, Can anyone tell the advantages/dis-advantages of adding a listener to the listeners collection? In MSDN it says that listeners not in the collection do not recieve all trace output. What...
6
by: Zytan | last post by:
According to http://www.15seconds.com/issue/020910.htm I am doing this in the c'tor of a 'logfile' class: objStream = new System.IO.FileStream(logFilename, System.IO.FileMode.OpenOrCreate);...
9
by: Mike | last post by:
Are there key listeners for Python? Either built in or third party?
5
by: Ayebaleet | last post by:
Hello everybody, I understand the basics of Java, but not such features as are helpful in an applet namely Listeners. I wanted to create a feature like this: A program would be displayed in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.