KeyPressEvent

J

James

Anyone can tell me why this code run well in JRE1.3 while in JRE 1.4.2, it
cannot run.
This code is when user press ctrl+space bar in the JFrame, the tab will set
to next tabindex and if user press shift+space bar, it will go to previous
tabindex.


private void formKeyPressed(java.awt.event.KeyEvent evt) {
// Add your handling code here:
KeyStroke
ky=KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SPACE,java.awt.Event.CT
RL_MASK);

if((ky.getKeyCode()==evt.getKeyCode())&&(evt.isControlDown())&&(tabpnPage.ge
tSelectedIndex()<tabpnPage.getTabCount()-1))
{
tabpnPage.setSelectedIndex(tabpnPage.getSelectedIndex()+1);
}
else
if((ky.getKeyCode()==evt.getKeyCode())&&(evt.isShiftDown())&&(tabpnPage.getS
electedIndex()>0))
{
tabpnPage.setSelectedIndex(tabpnPage.getSelectedIndex()-1);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top