Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking tab between JTextAreas

Status
Not open for further replies.

rdoor

Technical User
May 4, 2002
43
US
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
 
look for Key Bindings in swing components...
I will write later... Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top