Solved

Event/Focus/Key Listener Problem.

Posted on 1998-06-01
5
278 Views
Last Modified: 2010-04-16
I am trying to write a java GUI application where one of the screen is to have several buttons.  I want to make it where I can simply type in (using the keyboard) a specified key and have the focus transfer from one key to the specified key.  For example, if key "A" has the focus and I want key "C" to gain the focus from key "A", I just want to press key C on the keyboard and not use the mouse.  This application is written for a power user I guess.
I can make the focus traverse the button list so that's not what I want, I want the focus to pass button B if its presently on button A and I type C on the keyboard.
0
Comment
Question by:visa
  • 2
  • 2
5 Comments
 

Author Comment

by:visa
ID: 1221849
Edited text of question
0
 
LVL 4

Expert Comment

by:evijay
ID: 1221850
Write a focus manager class which maintains a list of buttons (vector) whose focus need to be
managed. This focus manager class implements the KeyListener interface. It registers itself as a valid keylistener for all the buttons in the list. Also, register this focusmanager class as key listener to the  parent of all the buttons When a key event occurs on a button, the focus manager class callback gets called. In this keyPress method, send the focus to appropriate component using requestFocus method of that component (button).
0
 
LVL 1

Accepted Solution

by:
niges earned 30 total points
ID: 1221851
evijay: as that is a correct answer, why didn't you post it as an answer...

--nige

0
 
LVL 1

Expert Comment

by:niges
ID: 1221852
D'oh please reject that answer, I meant it as a comment not answer.

--Nige
0
 

Author Comment

by:visa
ID: 1221853
I understand the solution for the most part, but I do not understand fully the part about the "parent" of the buttons.  I don't exactly understand what this "parent" is.  Please clarify this to me.  Thanks.

Visa
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ForLoop Example 3 48
egit plugin on eclipse 8 62
Why my table column Id is not passed to java object? 4 38
tomcat administrtor 12 46
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question