Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
Acmlm's Board - I3 Archive - Programming - [Java] This looks right, but... | New poll | | |
Add to favorites | Next newer thread | Next older thread |
User | Post | ||
neotransotaku Sledge Brother Liberated from school...until MLK day Since: 11-17-05 From: In Hearst Field Annex... Last post: 6433 days Last view: 6431 days |
| ||
it doesn't do what I intended
public void keyPressed(KeyEvent e) this code always lands me in default when I press Caps Lock... side note--if anyone knows how to disable br's inside pre with CSS, PM me with code, thanks. |
|||
Euclid Since: 11-17-05 From: Australia hmm... Last post: 6437 days Last view: 6431 days |
| ||
It looks right... assuming you did set a default value for typeMode (ascii or jpn) in some constructor before running that code.
The 2 mode variables seems to be man-made (static final ints?), i have no idea what type they are or if they're comparable, why don't you try an if statement instead and see if that works properly, and also try outputing the type of the variable before throwing an exception, that might help knowing why it has jumped to the default. |
|||
Squash Monster Bouncy Since: 11-18-05 From: Right next to myself. Last post: 6439 days Last view: 6432 days |
| ||
If the mode variables are ints, like Euclid guessed, then this code should work fine. If they're Strings or anything else you can't accurately use == with, then there's going to be a problem.
Or there could be a problem elsewhere in the program. Putting something like this in your default statement might bring something to light: System.out.println(typeMode + " : " + (typeMode == MODE_ASCII) + " : " + (typeMode == MODE_JPN)); |
|||
neotransotaku Sledge Brother Liberated from school...until MLK day Since: 11-17-05 From: In Hearst Field Annex... Last post: 6433 days Last view: 6431 days |
| ||
ack...i wasn't clear which default I was in.
The problem is the code thinks the caps lock key is not pressed, even when I am pressing the damn key. So...any ideas of how to get this code to recognize when caps lock is pressed. I also have a keyTyped function in the same class and it recognizes my keystrokes (so that rules out the fact that I have not added my listener). MODE_ASCII and MODE_JPN are static final ints and typeMode is initialized to MODE_ASCII |
|||
Euclid Since: 11-17-05 From: Australia hmm... Last post: 6437 days Last view: 6431 days |
| ||
Maybe it's your keyboard, try to find out the value for vk_caps_lock (i think it defaults to 0x20 for most cases) and the actual caps lock value on your comp, you might have to do some hardcoding... | |||
HyperHacker Star Mario Finally being paid to code in VB! If only I still enjoyed that. <_< Wii #7182 6487 4198 1828 Since: 11-18-05 From: Canada, w00t! My computer's specs, if anyone gives a damn. STOP TRUNCATING THIS >8^( Last post: 6432 days Last view: 6432 days |
| ||
It could just not be passing the Caps Lock key to the listener... add something to print the value of every key pressed, then hit Caps Lock a few times. If nothing gets printed, then you need to find another way to see when it's pressed. |
Add to favorites | Next newer thread | Next older thread |
Acmlm's Board - I3 Archive - Programming - [Java] This looks right, but... | | |