Solved

Event/Focus/Key Listener Problem.

Posted on 1998-06-01
5
262 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
Comment Utility
Edited text of question
0
 
LVL 4

Expert Comment

by:evijay
Comment Utility
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
Comment Utility
evijay: as that is a correct answer, why didn't you post it as an answer...

--nige

0
 
LVL 1

Expert Comment

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

--Nige
0
 

Author Comment

by:visa
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now