Value of VK_SHIFT + VK_A
Hi everybody,
If I want to send as an integer parameter the KeyEvent.VK_SHIFT + VK_A,
is that possible to do?
panel.add(makeLabelOption("-D", KeyEvent.VK_SHIFT + KeyEvent.VK_D));
Should that work? Or should I use something else?
thanks a lot
Marcelo
I have implemented this, maybe it works for others.
public class ShiftKeyListener implements KeyListener{
public void keyTyped(KeyEvent e){
char letter = e.getKeyChar();
int modifiers = e.getModifiersEx();
// Shift = 64, Ctrl = 128, Alt = 512
// Shift + Alt = 576
//String modifiersStr = KeyEvent.getModifiersExText(modifiers);
//System.out.println("the typed letter: "+ letter);
//System.out.println("Modifiers: "+modifiersStr);
if(modifiers != 576 && modifiers != 512)
return;
JCheckBox box = PanelTools.getCheckBox(letter);
if(box != null){
boolean checked = box.isSelected();
box.setSelected(!checked);
}
}
public void keyPressed(KeyEvent e){}
public void keyReleased(KeyEvent e){}
}
in java doc ,it says that the modifiers maybe changed in later versions,so you should write it like the following:panel.add(makeLabelOption("-D",KeyEvent.VK_SHIFT | KeyEvent.VK_D)