Hotkeys question  
Author Message
jaj_developer@yahoo.co.uk





PostPosted: 2005-4-6 16:39:00 Top

java-programmer, Hotkeys question All,

I am currently looking at doing the following. Using a JtextArea/field
create a box that will allow the users to enter hotkeys/shortcut keys.
When you click the box it will only take in the key pressed and display
that (e.g. if you press "a" A will appear, if you press crtl, alt,
shift and b "Crtl + ALT + SHIFT +B" would be displayed.

Does this class exist already (GPL pref).

Ta

Jaj

 
Arnaud Berger





PostPosted: 2005-4-6 16:46:00 Top

java-programmer >> Hotkeys question Hi,

You may want to deal with addKeyListener(KeyListener kl) method of
class java.awt.Component (also in JComponent).

The javadoc for KeyEvent should help you a lot also.

Regards,

Arnaud

<email***@***.com> a 閏rit dans le message news:
email***@***.com...
> All,
>
> I am currently looking at doing the following. Using a JtextArea/field
> create a box that will allow the users to enter hotkeys/shortcut keys.
> When you click the box it will only take in the key pressed and display
> that (e.g. if you press "a" A will appear, if you press crtl, alt,
> shift and b "Crtl + ALT + SHIFT +B" would be displayed.
>
> Does this class exist already (GPL pref).
>
> Ta
>
> Jaj
>


 
jaj_developer@yahoo.co.uk





PostPosted: 2005-4-6 17:10:00 Top

java-programmer >> Hotkeys question Arnaud,

Thats the way it currently is - and it doesn't function the way it
should.

Thanks for you advice though,

Jaj

 
 
Arnaud Berger





PostPosted: 2005-4-6 17:19:00 Top

java-programmer >> Hotkeys question Hi,

Could you please post the code you have so far ?

Regards,

Arnaud

<email***@***.com> a 閏rit dans le message news:
email***@***.com...
> Arnaud,
>
> Thats the way it currently is - and it doesn't function the way it
> should.
>
> Thanks for you advice though,
>
> Jaj
>


 
 
jaj_developer@yahoo.co.uk





PostPosted: 2005-4-6 18:18:00 Top

java-programmer >> Hotkeys question I don't have any - the reason I am asking here is 'cause I can see two
ways of doing this:-
1) Grab a java file (GPL) that has been written to do the setting up of
hotkeys
2) Write it myself.....

As such I'd like to go for option 1 ;-]

Jaj

 
 
Arnaud Berger





PostPosted: 2005-4-6 18:56:00 Top

java-programmer >> Hotkeys question This little attempt may help you :

public class KeyAdapt extends KeyAdapter{

public void keyPressed(KeyEvent e) {
System.out.println("key pressed , keychar: "+(char)(e.getKeyCode()));
System.out.println("Ctrl ? : "+e.isControlDown());
System.out.println("Alt ? : "+e.isAltDown());
System.out.println("Shift ? : "+e.isShiftDown());
System.out.println("All modifiers :
"+e.getKeyModifiersText(e.getModifiers()));
}

}

This class is also a KeyListener.
So just create your JTextField/Area and do
addKeyListener(new KeyAdapt());

Please note that this will get many events while a key is pressed (as of the
usual key repetition when
a key remains pressed)


So you may have to filter to avoid printing many times the "same" event .
That's up to you.

Cheers,

Arnaud


<email***@***.com> a 閏rit dans le message news:
email***@***.com...
> I don't have any - the reason I am asking here is 'cause I can see two
> ways of doing this:-
> 1) Grab a java file (GPL) that has been written to do the setting up of
> hotkeys
> 2) Write it myself.....
>
> As such I'd like to go for option 1 ;-]
>
> Jaj
>


 
 
jaj_developer@yahoo.co.uk





PostPosted: 2005-4-6 19:08:00 Top

java-programmer >> Hotkeys question thxs


Jaj