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 4 of 4

Thread: How can i control keyboard through programming?

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can i control keyboard through programming?

    Hello

    Suppose my program contain text area and I want change the
    layout of the keyboard to any order I want.

    The problem is how I can change the character what is in specify key?

    for example:

    If the user press The key (T) print in text area (J) directly
    without appear T and change it with J in text area.

    Thank you in advance.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How I can control Keyboard?

    Hello Mohd and welcome to the Java Programming Forums.

    I don't think its possible to swap the keyboards mapping in this way.

    What you could do is write an ActionListener method so that when a character is typed into the jtextarea, it is automatically updated and swapped with the desired character.

    I'm sure it will be quite complicated though.

    Have you wrote any code already? I will try to post some kind of example to help you get started..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How I can control Keyboard?

    Hi JavaPF,

    I solved this problem as you said
    I used ActionListener and when user type for example j
    type i or anything else

    in method keyTyped I used consume() to stop typing any character to jtextarea
    and in keyPressed() here was my coding.
    Get the character or keycode of the key and
    did what I want.

    Thank you.

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How I can control Keyboard?

    Hello Mohd,

    Thats brilliant! I'm glad you solved your problem.

    Would it be possible to post your code here? It may help others in the future
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 8
    Last Post: April 21st, 2013, 08:20 AM
  2. How to create a system wide mouse or keyboard hook?
    By Freaky Chris in forum Java Native Interface
    Replies: 17
    Last Post: June 17th, 2009, 01:06 PM
  3. How do I fix my program so I can use the keyboard to type in the numbers?
    By rocafella5007 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 29th, 2009, 02:39 PM