Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Overwrite what Keys do.

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Overwrite what Keys do.

    Hey guys,

    I'm looking for a way to overwrite what happens when a key is pressed. For example, show an image rather than text, or ignore it. If there is a class that does it that would be great. But I'm also looking for something more low level(not native code )


  2. #2
    Member
    Join Date
    Apr 2012
    Location
    Superior, CO, USA
    Posts
    80
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default Re: Overwrite what Keys do.

    Quote Originally Posted by Melawe View Post
    Hey guys,

    I'm looking for a way to overwrite what happens when a key is pressed. For example, show an image rather than text, or ignore it. If there is a class that does it that would be great. But I'm also looking for something more low level(not native code )
    If you're looking to do this at an O/S level (i.e. it happens in every application) you're going to have to "go native". If you're looking to do it in a single Java application, take a look at KeyListener
    Need Java help? Check out the HotJoe Java Help forums!

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Re: Overwrite what Keys do.

    I actually was reading that and the key bindings tutorial the other day. The problem with KeyListeners is I can't keep it from showing the text on the screen. What I want to do is, lets say, be able to type number "2" from the number row above the letters on the keyboard. But do something else when number "2" on the number pad is used.

    I don't want to use native code because Java is the only programming language I know atm, if I use native code I will have code I can't maintain on my own.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,332
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: Overwrite what Keys do.

    Quote Originally Posted by Melawe View Post
    I actually was reading that and the key bindings tutorial the other day. The problem with KeyListeners is I can't keep it from showing the text on the screen. What I want to do is, lets say, be able to type number "2" from the number row above the letters on the keyboard. But do something else when number "2" on the number pad is used.

    I don't want to use native code because Java is the only programming language I know atm, if I use native code I will have code I can't maintain on my own.
    What you describe is exactly what KeyBindings and KeyListeners are for. I'm not sure what the problem you describe is...do you mean you have a TextComponent and wish the component respond in a way to certain key events other than editing the text component?

  5. #5
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Re: Overwrite what Keys do.

    Quote Originally Posted by copeg View Post
    What you describe is exactly what KeyBindings and KeyListeners are for. I'm not sure what the problem you describe is...do you mean you have a TextComponent and wish the component respond in a way to certain key events other than editing the text component?
    Hmm, the key bindings tutorial was a bit confusing, Ill give it another go and report back. Thanks.

Similar Threads

  1. List of shortcuts key for Eclipse
    By Flash in forum Java JDK & IDE Tutorials
    Replies: 3
    Last Post: July 18th, 2013, 08:40 AM
  2. generate keys using j2ssh??????
    By rachana in forum Java Theory & Questions
    Replies: 2
    Last Post: February 3rd, 2011, 07:36 AM
  3. Eclipse: How to use/edit shorcut keys.
    By Truffy in forum Java JDK & IDE Tutorials
    Replies: 3
    Last Post: December 3rd, 2009, 11:51 AM
  4. combining keys
    By subhvi in forum Java SE APIs
    Replies: 10
    Last Post: August 29th, 2009, 04:35 PM
  5. List of shortcuts key for Eclipse
    By Flash in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: August 8th, 2008, 02:10 PM