Solved

Which control have focus?

Posted on 1998-08-17
4
145 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Ok, I will use keydown event´s evt.target to identify the control. Thanks!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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.

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

11 Experts available now in Live!

Get 1:1 Help Now