Traversing Focus By Enter Key
Please Try to Help Me on this ............
I Have a Screen where I need to traverse focus (it has textfields, combo boxes and buttons) when I press the Enter Key (like Tab).
I used a Key listener and was able to do it (to a certain point)
The code I have written is below ..
Now The problem is when the focus sets on a JComboBox, it wont go further (tab works). I know that the enter key in a JComboBox is used to select a item.
So what I need is first to be able to select an item using the enter key and when press enter key again, the focus must go to the next component.
Is there a way to do it ???
(JCheckBox and JButton has similar problems)
SymKey aSymKey = new SymKey();
textfield1.addKeyListener(aSymKey);
textfield2.addKeyListener(aSymKey);
combobox1.addKeyListener(aSymKey);
combobox2.addKeyListener(aSymKey);
checkbox1.addKeyListener(aSymKey);
textfield3.addKeyListener(aSymKey);
button1.addKeyListener(aSymKey);
class SymKey extends KeyAdapter {
public void keyPressed(KeyEvent e){
if (e.getKeyCode() == e.VK_ENTER) {
if (e.isShiftDown())
FocusManager.getCurrentManager().focusPreviousComponent((JComponent)e.getSource());
else
FocusManager.getCurrentManager().focusNextComponent((JComponent)e.getSource());
Hi,
You need to implement the focusmanager, and set currentfocusmanager with your focusmanger.Then it works out.Because Jcombobox is editable the keyevent of the combobox executes .
Hope it helps.
venkat
Similar Messages
-
DOWN Traversal out of JTextArea using SHIFT+ENTER key combination.
Hi folks
I slightly modified the focus-traversal code presented in Java Tutorial (http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html) to replace the CTRL+TAB combination with SHIFT-ENTER (because it is easier to type) but the code does not work. The code in the tutorial works for just ENTER key only. Am I making any mistake? Can anyone help me on this?
Thanks in advance.
AsifThanks for your reply, Srinath. Following is the code (in hyphenated borders):
=====================================================================
Set forwardKeys = getFocusTraversalKeys(
KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
Set newForwardKeys = new HashSet(forwardKeys);
newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK));
setFocusTraversalKeys(KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS,
newForwardKeys);
=====================================================================
Can you help me now? I would really appreciate it. Thanks
Asif -
Lose of focus (mouse click/enter key)
Hello,
we have a problem customers are complaining about for quite a while now, but despite our efforts, we can not fix it or at least determine with certainty the problem cause.
We have an application launching forms apps, and from time-to-time we completely lose the focus on this form (generally after typing ENTER in a filter), I mean by focus, we cannot click anymore (cursor seems to stay on a object), we cannot press enter anymore (we get a 'Not defined key function') and so on...
I heard somewhere that it could be due to 'KEY-OTHERS' trigger not handling correctly the ENTER-KEY. But I need this trigger for my filters, or is there another way? KEY_ENTER does only navigate from field to another.
I found something which was able to remove focus lost (kind of a hack while trying to fix this on an on), but the problem is I had to remove this, because it blocks the opening of new windows or popups. It was a mouse-click trigger on forms triggers level:
Go_Record(:System.Mouse_record);
Go_Item(:System.Mouse_Item);
But this blocks any window opening, and it also blocks some other tools we have developed.
Thanks,
Best regards,
G.
EDIT: Forms 11g, and I am pretty sure we had not that much problems with 10g
EDIT2: I read the same kind of topics in the forum, but no patch seems to help
AND we use JRE 1.7....
Edited by: lakers on Jan 14, 2013 11:56 PM
Edited by: lakers on Jan 14, 2013 11:59 PMthis problem occurs with some of versions of JRE. Try with JRE JInitiator 1.3.1.22. Also unstalled all others JRE if exists.
A file called fmrpcweb.res has also been provided which gives the Microsoft Windows client/server keyboard mappings. To use this file, rename fmrpcweb.res to fmrweb_orig.res, and copy fmrpcweb.res to fmrweb.res. Alternatively, use the term parameter as described above.
By default, whether deploying client/server or over the Web pressing the ENTER key takes the cursor to the next navigable item in the block. To override this default behavior it is necessary to modify the forms resource file to revise the key mapping details.
Modify fmrweb.res and change the Forms Function Number (FFN) from 27 to 75 for the Return Key. The line should be changed to the following:
10 : 0 : "Return" : 75 : "Return"
By default, the line is displayed with an FFN of 27 and looks as follows:
10 : 0 : "Return" : 27 : "Return"
This line should NOT fire the Key-Enter trigger since the Return or Enter key is actually returning the Return function represented by the FFN of 27. The FFN of 75 represents the Enter function and fires the Key-Enter trigger.
http://docs.oracle.com/cd/E24269_01/doc.11120/e24477/configure.htm#i1077054
please mark correct/helpful if problem is solved..
Edited by: Askdineshsinghminhas on Jan 15, 2013 5:28 AM -
Skip Enter Key and focus a field
Hi All
I need to :
1) skip pressing the enter key to refresh the screen after selecting a ralio button
2) focus a paticular field after selecting a radio button
Please tell me the tricks to perform these - I have looked up the help and SDN for these - but sofar - not much useful info found
Thanks in advance.Hi Liem,
Refer below thread and in that see the link of help.sap.com
Re: Set Variant in Program
Regards,
Atish -
How can I use the enter key instead of tab to change field focus?
I am using Acrobat 9 Pro.
We have a fillable PDF where the users enter numbers into fields. They want to be able to use the <enter> key on the 10-key pad instead of the <tab> key on the keyboard to move the focus to the next data entry field.
How can I set my PDF so that it recognizes the <enter> key instead of the <tab> key for changing focus?
Thanks!You can use a custom Keystroke script, something like:
// Custom Keystroke script for text field
if (event.willCommit && event.commitKey === 2) {
getField("Text2").setFocus();
Where "Text2" is the name of the next field. This doesn't disable the Tab key though. For more information, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.608.html -
No enter key or focus w/firefox
When testing with Firefox, my flash form doesn't allow the
enter key or the scroll wheel to function. Not can I set focus on a
particular field. That is, The field appears to be in focus, but
the cursor is not set to that field. I have to click it first
before I can type into it.On my MBP I can get "enter" by function-return.
charlie -
Detecting Enter key while textbox has focus....
It seems like in CS5 while using the tlf textfield that when the focus is in the textfield that the keyboard.enter key is not fired. However, outside it is. If I set my tab index to add the "login" button as the third tab index then the enter key works fine. But sometimes when I'm filling out a form when I'm in the last textbox I just hit enter. What's the workaround to have the enter key fired while focus is in the textfield?
Thanks,
CIt seems like in CS5 while using the tlf textfield that when the focus is in the textfield that the keyboard.enter key is not fired. However, outside it is. If I set my tab index to add the "login" button as the third tab index then the enter key works fine. But sometimes when I'm filling out a form when I'm in the last textbox I just hit enter. What's the workaround to have the enter key fired while focus is in the textfield?
Thanks,
C -
Focus navigation with enter key between controls
hi,
i've an app and i wanna change control focuses one to other one with pressing enter key..i think keyFocusChange property solve my prob but i couldnt fix it..
text input
button
helppp pls.
thnxthnx krafttimd for help..
i solved it with an easily way..i used textInput s enter event and generate a handler.
<s:TextInput id="kod" enter="kod_enterHandler(event)" />
<s:TextInput id="sifre" enter="sifre_enterHandler(event)" />
<mx:Button id="giris" keyDown="giris_keyDownHandler(event)" click="checkLogin()"/>
protected function kod_enterHandler(event:FlexEvent):void{
sifre.setFocus();
protected function sifre_enterHandler(event:FlexEvent):void{
giris.setFocus();
protected function giris_keyDownHandler(event:KeyboardEvent):void{
if(event.keyCode == Keyboard.ENTER) checkLogin();} -
Hi folks,
I'd like to make the ENTER key behave the same way as the TAB key in
the system I'm developing. I thought I would be able to do it by setting
the ENTER as a function key (using Window.SetAsFunctionKey), and
then after detecting an ENTER key press, request focus on the current
fieldwidget's 'NextTabField'. However, this attribute defaults to NIL unless
you override the default TAB sequence. And I don't really fancy setting
the Next and Prev TabField for every onscreen field.
Anyone done this before using a simpler method?
By the way, I don't really want to get into a long thread about whether it is
good practice to bypass Windows (TM) standards or not. We require
fast data entry, and keyboard entry is essential for that.
Cheers,
Duncan Kinnear,
McCarthy and Associates, Email: [email protected]
PO Box 764, McLean Towers, Phone: +64 6 834 3360
Shakespeare Road, Napier, New Zealand. Fax: +64 6 834 3369
Providing Integrated Software to the Meat Processing Industry for over 10 years
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Duncan,
The application we are building will replace legacy application and had similar
requirements to accommodate the current users. We solved this problem by creating a
special frame, appropriately named as the "Terminal Frame". It is distributed as
part of the Scaffolds framework.
The Terminal frame implements ENTER instead of TAB key. As you know the tabbing
order in a terminal frame (top to bottom, left to right) is different than windows
tabbing order (left to right, top to bottom). The Terminal frame solves the tabbing
problem by constructing a "field traverse list" which includes all the fields in a
window including nested views ordered according to their X,Y co-ordinates. It is a
recursive method works on the same lines as described by Sakharov, Nickolay in
earlier mail. The method also sets the NextTabField, PrevTabField references for
each field in the traverse list.
This framework is working very well for us. In a terminal frame world, you still
have some user training issues as some of the fields (OutlineField, DropList,
ArrayField, CheckBoxe etc.) behave differently for ENTER and TAB keys. But these
are minimal compared to a complete change in style.
Hope this is helpful.
Good Luck,
Shirish
Duncan Kinnear wrote:
On 22 Jun 99, at 23:47, Jeanne Hesler wrote:
Do the math on this one. Be sure your users understand the cost and the
lack of payback. I have no problem going against common practice when
there is a good reason, but this reason just doesn't add up. Even if it
did slow them down, which it won't, they would never lose enough time to be
worth the work that it would take to implement.Jeanne,
Thanks for your reply (even though it doesn't help me!).
Don't get me wrong, I'm not advocating we abandon the TAB key
functionality in favour of the ENTER key. I just want to ADD the ENTER
key as a navigational aid for our 'legacy' users (and we have many). If it
is done right, there should be no need to tell the user about it. Their
transition to the new product would be virtually painless.
Since I posted my original question I've realised that the cost of
implementation is actually fairly low. And this is why. I have just
discovered that the default tab order defined by Forte (left to right, top to
bottom) is essentially useless for most of the windows we will be creating.
Therefore, we will need to override it by explicitly setting the
"NextTabField" and "PrevTabField" attributes of our input fields in virtually
every window. As I am writing the framework for our new product, I will
have to implement the facility to do this in the framework itself. And if we
have our tab order defined, then adding the ENTER key functionality is
minimal extra effort (see my original post). In fact, if I implement it in my
"CoreWindow" (the root of my windows framework inheritence tree), then
no-one will ever have to deal with it again.
The TAB key is not even much of a windows data-entry standard. Many
of our customers have defined secondary systems using Microsoft
Access, and it uses the ENTER key (along with the TAB key) to move
from field to field. Will these customers not complain that they cannot
use the ENTER key to move between fields if we don't implement it?
As we do not have the resources to completely rewrite our existing
COBOL system (over 2 million lines of code) in one go. We will be rolling
out the new system module by module. This means that a lot of our users
will be switching between the new windows interface and the text-based
unix telnet sessions. When I switch back and forth between windows
editors and 'vi' on the unix host, I experience first-hand how mixed
navigational facilities can hamper productivity!
Anyway, I was just hoping there might be a little setting somewhere in
Forte to switch this on, but as no-one has pointed it out, it seems unlikely.
Thanks again for your input, lively discussion is always welcome.
Cheers,
Duncan Kinnear,
McCarthy and Associates, Email: [email protected]
PO Box 764, McLean Towers, Phone: +64 6 834 3360
Shakespeare Road, Napier, New Zealand. Fax: +64 6 834 3369
Providing Integrated Software to the Meat Processing Industry for over 10 years
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>--
Shirish Kulkarni <mailto:[email protected]>
Sage IT Partners <http://www.sageitpartners.com>
44 Montgomery St. Suite 3200 San Francisco, CA 94104
(925)210-6965 Office (415) 399-7001 Fax
The Leaders in Internet Enabled Enterprise Computing
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/> -
Making ENTER key act as a TAB key.
I have a version problem that I could not solve. My goal is using ENTER key as TAB key.
In java version 1.3.X my code is working properly.It is like the code below
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) e.setKeyCode(KeyEvent.VK_TAB);
In java version 1.4.X it is not working. Can anybody help me please?Thanks a lot. It is really a good document that everybody should read.
I have copied some portion of it for others searching about this topic.It is below.
KeyListeners installed on Components will no longer see KeyEvents that map to focus traversal operations. Previously, AWT Components saw these events and had an opportunity to consume them before the AWT initiated focus traversal. Code that requires this functionality should instead disable focus traversal keys on its Components and handle focus traversal itself. Alternately, the code can use an AWTEventListener or KeyEventDispatcher to pre-listen to all KeyEvents. -
Trap enter key? please help
how will i trap the enter key?
example: jTextField1 has the focus or insertion point, if the user presses the enter key from the keyboard the next focus or insertion point will be on jTextField2.
thank you in advance.
killuasoftSwing related questions should be posted in the Swing forum.
By default a "Tab" key is used as the "focus traversal key". You can also add the "Enter" key as a focus traversal key to any given component.
I'll let you read the Swing tutorial for information on how to do this. -
Is it possible - "pust enter key" and "execute go button"
Hi guys,
I want to execute the go button when I push the enter key from keyboard...
Is it possible?
Regards.hi mate - i think i know what you're trying to do... you're trying to "set focus" on the GO button so on "enter" the go button automatically fires off.
couple of problems with this (from what i see).
1. if you have multiple prompts on the dashboard then you have more than one "GO" button to click on... which one should you default to?
2. targeting the Go button using javascript would be a custom job and burn time, traversing the DOM to find the right "GO" button to set focus on....
... if possible I would just say "it can't be done" to the end user... is that an option? -
How to call a method in backing bean on hitting 'Enter' key on a page.
Hi all,
I would be obliged if any one can provide me solution for the below given problem.
My requirement is to call a method in backing bean when i hit 'Enter' key on a JSP page.
I am trying this by using a script given below.
*function fnChangeFocus(){*
*if(window.event.keyCode==13){*
* document.getElementById("mainform:submitForm:commandbutton").focus();*
The JSP has the textbox as given below.
*<h:inputText id="inputtxtboxid" disabled="false" value="#{Bean.inputvalue}"*
onkeypress="fnChangeFocus()" size="24" />
Using this I could not acheive the required functionality. Please suggest some alternative.
Thanks,
Jagadeesh PalaOnly a form element supports the submit() function. Make sure that the getElementById returns the appropriate form. Or rather pass the element as the 'this' reference to the function and get the parent form from it.
After all this is just basic DHTML / Javascript+DOM knowledge and in fact this has nothing to do with JSF. For future basic DHTML / JS+DOM questions you may take a look at the appropriate forums, e.g. dhtmlcentral.com, dynamicdrive.com, etcetera. -
Arrow keys and enter key not functioning in Firefox 3.6 when viewing PDF
I'm using Adobe Reader 9.3.0.
I have a web application that displays PDFs (using Adobe Reader) in a browser. The PDF is loaded onto the page inside an IFRAME. In addition to the IFRAME containing a PDF, the page also includes several forms, text fields, etc. For the most part this is working fine. However, I have a glitch when using this in Firefox 3.6. I'm finding that certain keyboard events are being lost and I strongly suspect that they are being swallowed by Adobe Reader. When I place focus on an HTML text field and press enter key or arrow keys, I do not get the appropriate key events. If I run the exact same test without the PDF IFRAME these key events work correctly, but as soon as I load the PDF into the IFRAME they do not. I believe the primary key event that gets lost is the keydown event. I do get the keyup event.
Again, the events work correctly up until I load the PDF onto the page.
I've verified that this error does not occur in Firefox 3.5 and 3.0.
Here is a testcase to reproduce this:
<html>
<head>
<title>JavaScript - Detecting keystrokes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var pdfURL = 'http://samplepdf.com/sample.pdf';
window.onload = function () {
init();
document.defaultAction = true;
function init() {
var x = document.getElementById('testForm').getElementsByTagName('input');
for (var i=0;i<x.length;i++) {
x[i].onclick = setEvents;
if (x[i].checked)
x[i].onclick();
writeroot = document.getElementById('writeroot');
document.getElementById('emptyWriteroot').onclick = function () {
writeroot.innerHTML = '';
return false;
function setEvents() {
if (this.id == 'default') {
document.defaultAction = !this.checked;
return;
var eventHandler = (this.checked) ? detectEvent : empty;
document.getElementById('textfield')['on'+this.id] = eventHandler;
//document['on'+this.id] = eventHandler;
function detectEvent(e) {
var evt = e || window.event;
writeData('<b>'+evt.type+'</b>: keyCode=' + evt.keyCode+' : charCode=' + evt.charCode);
return document.defaultAction;
function empty() {
// nothing
var writeroot;
function writeData(msg) {
writeroot.innerHTML += msg + '<br />';
</script>
<style type="text/css">
body {
font-size: 12px;
#writeroot {
height: 300px;
overflow: auto;
border: 1px solid #2EB2DC;
</style>
</head>
<body>
<form id="testForm">
<input type="checkbox" id="keydown" /> <label for="keydown">keydown</label><br />
<input type="checkbox" id="keypress" /> <label for="keypress">keypress</label><br />
<input type="checkbox" id="keyup" /> <label for="keyup">keyup</label><br />
<input type="checkbox" id="default" /> <label for="default">Suppress default action</label><br />
<input type="text" id="textfield" /><br />
<button id="emptyWriteroot">Remove messages</button>
</form>
<a href="#" onclick="document.getElementById('docviewer-page').src=pdfURL;return false">Now load IFrame</a>
<p id="writeroot"></p>
<div id="container2" style="border:1px solid black;width:400px;height:200px">
<iframe
id='docviewer-page'
name='docviewer-page'
title='document page'
src='http://www.google.com'
align='left'
width='100%'
height='100%'
scrolling='auto'
frameborder=0></iframe>
</div>
</body>
</html>
Paste the above into an HTML document. Open the HTML document in Firefox 3.6. Check the four checkboxes. Move into the text field and press arrow keys and enter key to observe the results when it is working correctly. Then click on the "Now Load PDF" link. Press the arrow keys and enter key again and observe that the behavior has changed.
Anybody have any idea why this is happening or how to work around it?I found a workaround!
By using an object tag instead of an iframe, all the keys seems to work fine and the PDF still renders in the page the same way.
Here's a page that works:
<html>
<head>
<title>JavaScript - Detecting keystrokes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var pdfURL = 'http://samplepdf.com/sample.pdf';
window.onload = function () {
init();
document.defaultAction = true;
function init() {
var x = document.getElementById('testForm').getElementsByTagName('input');
for (var i=0;i<x.length;i++) {
x[i].onclick = setEvents;
if (x[i].checked)
x[i].onclick();
writeroot = document.getElementById('writeroot');
document.getElementById('emptyWriteroot').onclick = function () {
writeroot.innerHTML = '';
return false;
function setEvents() {
if (this.id == 'default') {
document.defaultAction = !this.checked;
return;
var eventHandler = (this.checked) ? detectEvent : empty;
document.getElementById('textfield')['on'+this.id] = eventHandler;
//document['on'+this.id] = eventHandler;
function detectEvent(e) {
var evt = e || window.event;
writeData('<b>'+evt.type+'</b>: keyCode=' + evt.keyCode+' : charCode=' + evt.charCode);
return document.defaultAction;
function empty() {
// nothing
var writeroot;
function writeData(msg) {
writeroot.innerHTML += msg + '<br />';
</script>
<style type="text/css">
body {
font-size: 12px;
#writeroot {
height: 300px;
overflow: auto;
border: 1px solid #2EB2DC;
</style>
</head>
<body>
<form id="testForm">
<input type="checkbox" id="keydown" /> <label for="keydown">keydown</label><br />
<input type="checkbox" id="keypress" /> <label for="keypress">keypress</label><br />
<input type="checkbox" id="keyup" /> <label for="keyup">keyup</label><br />
<input type="checkbox" id="default" /> <label for="default">Suppress default action</label><br />
<input type="text" id="textfield" /><br />
<button id="emptyWriteroot">Remove messages</button>
</form>
<a href="#" onclick="document.getElementById('docviewer-page').data=pdfURL;return false">Now load IFrame</a>
<p id="writeroot"></p>
<div id="container2" style="border:1px solid black;width:400px;height:200px">
<object
id='docviewer-page'
name='docviewer-page'
title='document page'
data='http://www.google.com'
align='left'
width='100%'
height='100%'
></object>
</div>
</body>
</html> -
Problem with enter key in the quiz templates
hi,
I need some i am using quiz templates and my problem is when
i make the swf file and test the quiz it works good , but when i
press the enter key , the quiz doesn't work and repeat and go to
the first screen , i don't know if i have to block the enter key or
how i can resolve this ?
Thanks a lotI know that focus management has changed alot.
Based on my experimentation a while back, in 1.4 it still believes that the JFrame is the window in focus, even though a JOptionPane is currently in front of it (unless I misinterpreted what was going on). Thus, the frame seems to get the keyboard event and re-invoke the action.
A.F.
Maybe you are looking for
-
Dear forum, Firstly many apologies if this is a stupid question or if it has been answered before, but I'm very new to using FormsCentral only in the past few days. I purchased an Individual Creative cloud, single app plan at £17.58 per month for onl
-
Screen is blurry and shaking.
I always turn my iPhone off every night. And this morning my iPhone 4s screen is blurry and kind of shaking. What am I suppose to do? because I never dropped my phone or get any waters to it.Also my signal bar and the battery bar is kind of cut into
-
Cannot sign in due to a server error
Ok, so I cannot sign into my iCloud account on my Windows 7 (32bit) PC. I have done the "winsock" reset in addition to a "bonjour" reset... whats next on the list aside from reinstalling my Windows OS?
-
I am not able to connect planning through workspace
Hi, i am able to login to workspace, and when i select the planning application from workspace i got error like your session has timed out or was terminated by the application owner or an administrator.please log on again. but i can able to login the
-
Premiere Elements 10, unable to launch projects...
Hi there, first post. I've managed to sort out one problem already this morning - I've now got virtualdub set up for processing files before I import them to PE. However I'm still stumped on why it (at the moment) still crashes (just 'stopped working