I have a small application which I've developed to drill math facts for kids. It is made up of a series of 30 JPanels in a JFrame, each displaying a problem and having a JTextArea for input. With ENTER, the answer is analyzed and recorded. We've found that sometimes the kids will simply tab through the JPanels and answer only the ones which they know. I've been able to disable the ENTER so that it stays put if the JTextArea is blank, but I need to disable the TAB also. Interestingly, I've tried to assign the TAB key to the ENTER, thusly:
enterAnswer.addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == KeyEvent.VK_TAB){
e.setKeyCode(KeyEvent.VK_ENTER);
}
}
and nothing happens. As a matter of fact, when I ask for a getKeyText(getKeyCode()) to console, I get a nice output for every key except the TAB key! Does this have to do with the fact that the TAB key is busy tabbing and is "consumed" before the console gets to it?
Also, how do I block the kids from mousing from one JPanel to the next?
I'm stumped!
Roy from Iowa working with a small school
enterAnswer.addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == KeyEvent.VK_TAB){
e.setKeyCode(KeyEvent.VK_ENTER);
}
}
and nothing happens. As a matter of fact, when I ask for a getKeyText(getKeyCode()) to console, I get a nice output for every key except the TAB key! Does this have to do with the fact that the TAB key is busy tabbing and is "consumed" before the console gets to it?
Also, how do I block the kids from mousing from one JPanel to the next?
I'm stumped!
Roy from Iowa working with a small school