Solved

Event/Focus/Key Listener Problem.

Posted on 1998-06-01
5
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

729 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