Is it possible to detect a key event of Ctrl-[Up/Down]?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mark_Shearman
Posted On:   Tuesday, April 9, 2002 01:57 AM

I am trying to make Ctrl-Up and Ctrl-Down move the selected row of a JTable up and down respectively... any ideas?

Mark

Re: Is it possible to detect a key event of Ctrl-[Up/Down]?

Posted By:   Mark_Shearman  
Posted On:   Wednesday, April 10, 2002 02:50 AM

Sorry - should have looked into it before asking question!


Is actually very easy but just in case anyone happens to come across this question looking for similar info in future...



In your KeyListener:

public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP &&
e.isControlDown()) {
//carry out up action
} else if (e.getKeyCode() == KeyEvent.VK_DOWN &&
e.isControlDown()) {
//carry out down action
}
}

Mark
About | Sitemap | Contact