Solved

Which control have focus?

Posted on 1998-08-17
4
146 Views
Last Modified: 2010-04-16
How can I identify the control that have focus in an Applet? Im using Visual J++ 1.1 (JDK 1.0).
0
Comment
Question by:pengch
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
jdyer earned 50 total points
ID: 1221979
since you are using JDK 1.0 you should utilize the gotFocus message handler

Object focObj;

public boolean gotFocus( Event evt, Object arg )
{
focObj = evt.target;
}

this saves which object last received the focus, hence the one that currently has the focus.

Regards,
  jdyer
0
 

Author Comment

by:pengch
ID: 1221980
I have several textfield in an applet. I need to identify which textfield having focus to emulate tab and limite the maximum caracter per field. But using method gotFocus of Applet, when a textfield adquire focus the method does not called (using Internet Explorer).
0
 
LVL 1

Expert Comment

by:jdyer
ID: 1221981
How about lostFocus? Does that work in Internet Explorer.

Another hack of a sort would be to capture keyEvents, whichever TextField the last KeyEvent was in, save that and treat it as the one with Focus. There are obvious limitations of course. I don't know of anything else you could do though.

Generally this is difficult to do in JDK1.0.2, that's why the capability was added inherently in JDK1.1 and above.
0
 

Author Comment

by:pengch
ID: 1221982
Ok, I will use keydown event´s evt.target to identify the control. Thanks!!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java - Why doesn't this JFrame work 3 59
fibonacci ten numbers 4 38
iterator/ListIterator approach 17 27
Desingning Refactoring existing code 2 24
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

773 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