(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
06-01-24 08:09 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - [Java] This looks right, but...
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
HyperHacker
Posts: 283/5072
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.
Euclid
Posts: 13/83
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...
neotransotaku
Posts: 176/1860
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
Squash Monster
Posts: 72/296
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));
Euclid
Posts: 12/83
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.
neotransotaku
Posts: 170/1860
it doesn't do what I intended

  public void keyPressed(KeyEvent e)

{
switch(e.getKeyChar())
{
case(KeyEvent.VK_CAPS_LOCK):
switch(typeMode)
{
case(MODE_ASCII):
typeMode = MODE_JPN;

break;
case(MODE_JPN):
typeMode = MODE_ASCII;
break;
default:
throw new IllegalArgumentException("Invalid TypeMode");
}
break;
default:
System.out.println(KeyEvent.getKeyText(e.getKeyChar()));
}
}


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.
Acmlm's Board - I3 Archive - Programming - [Java] This looks right, but...


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.010 seconds; used 350.47 kB (max 390.70 kB)