Solved

Which control have focus?

Posted on 1998-08-17
4
149 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 52
How to convert String matching to regex in java 4 50
hibernate example using maven 12 58
Java: The Public Class Main 4 32
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 will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

829 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