Solved

Which control have focus?

Posted on 1998-08-17
4
152 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
Maven Project: Hibernate Dependencies Conflict 10 50
java example issue 5 43
junit example issue 2 25
Strange router problem - can't access hotmail.com 14 53
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

749 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