Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help On BlueJ: Inputting Keys

ZeromatterZeromatter Posts: 3Member
I'm sorry for posting a topic that may have already been posted, but I REALLY need help!

how do you get it so that if a user presses a key, such as 's', a message is displayed via terminal that says something like, "you pressed s!!!"???

Any help would be GREATLY appreciated,

Comments

  • zibadianzibadian Posts: 6,349Member
    : I'm sorry for posting a topic that may have already been posted, but I REALLY need help!
    :
    : how do you get it so that if a user presses a key, such as 's', a message is displayed via terminal that says something like, "you pressed s!!!"???
    :
    : Any help would be GREATLY appreciated,
    :
    Implement the KeyListener interface. That interface defines a keyPressed() method, which is fired if the user presses a key.
  • ZeromatterZeromatter Posts: 3Member
    : Implement the KeyListener interface. That interface defines a keyPressed() method, which is fired if the user presses a key.
    :

    I'm sorry, but I am not too adept at programming in Java. Frankly, all I know is a semester course. If you would be so kind to give a code example, I would be extremely thankful.
  • zibadianzibadian Posts: 6,349Member
    : : Implement the KeyListener interface. That interface defines a keyPressed() method, which is fired if the user presses a key.
    : :
    :
    : I'm sorry, but I am not too adept at programming in Java. Frankly, all I know is a semester course. If you would be so kind to give a code example, I would be extremely thankful.
    :
    I myself also just took an introduction course in Java programming, but EventListeners were among the first things we learned. Here is the basic code, the you should look in the javadoc for the rest:
    [code]
    public class MyApplet extends Applet implements KeyListener
    {
    public void init()
    {
    thiss.addKeyListener(this);
    }

    public void keyPressed(KeyEvent event)
    {
    }
    }
    [/code]
  • ZeromatterZeromatter Posts: 3Member
    Thanks a great deal. This will be extremely useful.
Sign In or Register to comment.