How to alter behaviour of pressing enter key to tab key?

Hi! I want to alter the behaviour when pressing the enter key so it acts like pressing the tab key in a JTextField. That is pressing the enter key will transfer the cursor to the next field instead of the cursor just staying in the current field.
Thanks in advance.
rralilin

Hi,
there are more than one way to do this:
1. use an ActionListener and transfer the focus in its actionPerformed(...) method - good for one or a few JTextFields - if there are more, try ...
2. prelisten the key events via the new KeyboardFocusManager und replace the corresponding key event by a Tab-key-event and redispatch it - this approach enables you, to handle this new behavior for all JTextFields in one central position - possible since JDK 1.4
Hope, this helps
greetings Marsian

Similar Messages

  • Time formatet string in thtmlb dropdownlistbox after enter key or tab key

    Dear Collegues,
    In our BSP-Application we use the thtmlb:dropdownlistbox. It's configured as you can see below in the code cutout:
    DATA: wa_result type ZZPRBRS_PRSRG.
                      %>
                      <td>
                      <thtmlb:dropdownListBox id        = "DD_PREISREGEL"
                                              selection = "<%= DD_PREISREGEL %>"
                                              editable  = "TRUE" >
                        <%
      loop at APPLICATION->PRREG_TAB into wa_result.
                        %>
                        <thtmlb:ddlbItem key   = "<%= wa_result-PRSRG %>"
                                         value = "<%= wa_result-PRSRG %>" />
                        <%
      endloop.
      clear wa_result.
                        %>
                      </thtmlb:dropdownListBox>
    As you can see the ddlb is set as editable.
    So far so good.
    But when we edit the entry in the box and leave the box with ENTER KEY or TAB KEY the controlle change the format of the entry to a kind of time format. Excamlpe:
    We choose the entry GSVIES2 (one of the list entries) and we edit it to GSVIES22 the controll change it to 22:00. Longer entries will be changed to an entry like xx:xx:xx.
    The wa_result-PRSRG for the entries is an char(12).
    I found no notes about this issue.
    Does anybody know this behave?
    How can we avoid that changing after editing?
    Kind regards
    Thomas

    Hi Thomas,
    I was wondering, if you really want to have an editable DropDownlistbox, did they advise anything?
    And, what do you think; should I go ahead and extent the THTMLB library with a ZDropDownlistbox which doesn't use the 'timepicker' javascript?
    references to my questions:
    BSP extensions: THTMLB
    dropdownlistbox classes: CL_THTMLB_DROPDOWNLISTBOX, CLG_THTMLB_DROPDOWNLISTBOX
    In the class: CL_THTMLB_DROPDOWNLISTBOX method IF_BSP_ELEMENT~DO_AT_END calls this JavaScript
    *     Building a unique variable name (simply based on a new tag ID):
          lv_guid_str = me->generate_tag_id( ).
          CONCATENATE  'v_' lv_guid_str
                 INTO  js_unlisted_timepicker_key.              "#EC NOTEXT
    *     Building the script retrieving the KEY and saving it into that variable:
          CONCATENATE  `var ` js_unlisted_timepicker_key
                       ` = thtmlbConvertTimeToKey("`
                       js_new_selected_value
                       `"); `
                 INTO  lv_script.
    Kind regards,
    Sander

  • Enter key as Tab Key in a JTable

    How can I have the Enter Key act as a Tab Key in a JTable?

    thnx...but I already solved my problem. In case someone has the same problem:
    final InputMap im = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    im.put(key, "selectNextColumnCell");

  • How to set current row in table after use tab key on inputText

    Hello all,
    My first post .., I'm newbie in ADF and I will try to explain my problem.
    For the moment we use ADF 11g (11.1.1.4), in a jsff page I have a table with an inputText column.
    On the valueChangeListener of the inputText, I invoke a method in a viewScope bean which call an EJB method, make some services in the EJB on the line modified. After that I refresh the VO and the table (because others values on the line have been modified) and reset the focus on the same inputText modified by the user with javaScript because focus was lost after refresh.
    So far, everything works fine.
    When I use the arrow keys to change the selected row in the table, it's work fine (focus is still in the next or previous inputText), but if user try to use tab key to change the current line, the inputText on the next line have the focus but the current row of the table is not changed (I think it's normal).
    My question : how can I change the current row after tab key pressed in this case ?
    I don't know if it's really clear, not easy to explain, don't hesitate to ask more details.
    Thanks in advance.

    Frank Nimphius wrote:
    Hi,
    My question : how can I change the current row after tab key pressed in this case ?
    Use a client event to listen for the keyboard entry and intercept the tab. The use af:serverListener to call the server to set the rowKey on the table and issue a PPR for the table to re-paint
    See sample 11 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
    to learn about how to use the client listener and server listener
    FrankHi,
    Thanks a lot for your advices, I used the client and server listener
    I used this code on the method call in order to change the selection after key tab pressed, I don't know if it can be easier, but it works.
              if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("START changeSelectedRow");
              RowKeySet oldRowKeySet = myTable.getSelectedRowKeys(); // get oldRowKeySet
              if (oldRowKeySet == null) {
                   if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("oldRowKeySet is null");
                   return;
              RowKeySetImpl newRowKeySet = new RowKeySetImpl(); // The new RowKeySet use to change the selectedRow
              DCIteratorBinding bindingIterator = ADFUtils.findIterator(MY_ITERATOR);
              bindingIterator.setRangeSize(-1);
              // set the new index of the current row.
              int index = bindingIterator.getCurrentRowIndexInRange();
              if (index < bindingIterator.getAllRowsInRange().length - 1) {
                   index++;
              bindingIterator.setCurrentRowIndexInRange(index);
              // get the current row after changed the index
              Row currentRow = bindingIterator.getCurrentRow();
              if (currentRow != null) {
                   ArrayList nextLst = new ArrayList(1);
                   nextLst.add(currentRow.getKey());
                   newRowKeySet.add(nextLst);
                   // set the new selectedRow
                   myTable.setSelectedRowKeys(newRowKeySet);
                   SelectionEvent selectionEvent = new SelectionEvent(oldRowKeySet, newRowKeySet, myTable);
                   selectionEvent.queue();
                   AdfFacesContext.getCurrentInstance().addPartialTarget(myTable);
              if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug("END changeSelectedRow");
    Best Regards
    Benjamin

  • Enter key instead of TAB key

    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/>

  • Press Enter or Tab to advance

    Is is possible to have the user press the Enter key or Tab key to advance to the next field?
    How do I set that???
    Thank you!

    use a caret listener and when it fires, check the length and switch focus to whatever

  • 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.

  • Tab key selects cell for edit in JTable

    Hello,
    I've seen extensive posts on this forum for this problem, but no solution yet.
    I have a Jtable, with custom cellRenders and cellEditors. Some columns are editable, some are not.
    What I want to do, is when someone tabs to an editable cell, that cell immediately goes into edit mode. This means, it acts as if someone double clicked on it, or tabbed then clicked on it. Basically, I want it to ACTUALLY go into edit mode.
    Please do not respond by telling me how to make it look editable (highlighting, etc) and do not respond with mouseEvent solutions. Please do not respond by telling me to do table.editCellAt(row,col) because that does not kick in my custom editor, it uses the defaultCellEditor.
    So basic question:
    How to kick in editing when someone tabs to an editable cell?
    If you need code examples, please request and I will post.

    nmstaat,
    In JTable:
    Look into the processKeyBinding method. It takes a keyevent and matchs it with an InputMap, and the InputMap invokes an Action in the corresponding ActionMap.
    You will have to call yourJTable.getActionMap(), then alter the action that corresponds to the 'tab' key.
    For Further information, check the JTable API, its all there.
    Good Luck,
    Alex
    Here's the current map for the Metal look and feel:
    JTable (Java L&F)
    Navigate out forward | Tab
    Navigate out forward | Ctrl+Tab
    Navigate out backward | Shift+Tab
    Navigate out backward | Ctrl+Shift+Tab
    Move to next cell | Tab
    Move to next cell | Right Arrow
    Move to previous cell | Shift+Tab
    Move to previous cell | Left Arrow
    Wrap to next row | Tab
    Wrap to next row | Right Arrow
    Wrap to previous row | Shift+Tab or Left
    Wrap to previous row | Shift+Tab or Left
    Block move vertical | PgUp, PgDn
    Block move left | Ctrl+PgUp
    Block move right | Ctrl+PgDn
    Block extend vertical | Shift+PgUp/PgDn
    Block extend left | Ctrl+Shift+PgUp
    Block extend right | Ctrl+Shift+PgDn
    Move to first cell in row | Home
    Move to last cell in row | End
    Move to first cell in table | Ctrl+Home
    Move to last cell in table | Ctrl+End
    Select all cells | Ctrl+A
    Deselect current selection | Up/Down Arrow
    Deselect current selection | Ctrl+Up/Down Arrow
    Deselect current selection | Pgup/Pgdn
    Deselect current selection | Ctrl+Pgup/Pgdn
    Deselect current selection | Home/End
    Deselect current selection | Ctrl+Home/End
    Extend selection one row | Shift+Up/Down
    Extend selection one column | Shift+Left/Right
    Extend selection to beginning/end of row | Shift+Home/End
    Extend selection to beginning/end of column | Ctrl+Shift+Home/End
    Edit cell without overriding current contents | F2
    Reset cell content prior to editing | Esc

  • About TAB key

    Hi, i hope you can help me a little....!!!
    Thank's anyway =)
    Look, in a page when I have some textbox, i can go thougth then with TAB key. If i want to return i have to press Shift key with TAB key...
    My question is: Is there some instrucction to mark the text in a control when it is selected ??? or all this is automatic, i mean, the selection of text in a control is select automatly when the control has the focus????...
    Thanks!!!....
    I'm wait four your answer!!!
    Have a nice day!!!
    NOTE: AS YOU CAN SEE, MY ENGLISH IS NOT VERY WELL, BUT I TRAY TO EXPLAIN MY PROBLEM.... THANK'S AGAIN.... =)

    Read the section from the Swing tutorial on "Writing Event Listeners":
    http://java.sun.com/docs/books/tutorial/uiswing/events/index.html
    The following code is an example of a Focus Listener that will select all the text in the text field when you tab to a field or use the mouse to click on it:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.plaf.basic.*;
    import javax.swing.plaf.*;
    public class TextFieldTest extends JFrame
        public TextFieldTest()
              FocusAdapter focusAdapter = new FocusAdapter()
                   public void focusGained(FocusEvent e)
                        JTextComponent component = (JTextComponent)e.getSource();
                        component.selectAll();
              JTextField textField1 = new JTextField( "one two three four five" );
              textField1.addFocusListener( focusAdapter );
              getContentPane().add( textField1, BorderLayout.NORTH );
              JTextField textField2 = new JTextField( "abcdefg" );
              textField2.setMargin( new Insets( 5, 5, 5, 5 ) );
              textField2.addFocusListener( focusAdapter );
              getContentPane().add( textField2, BorderLayout.SOUTH );
        public static void main(String[] args)
         TextFieldTest frame = new TextFieldTest();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setVisible(true);
    }

  • How to get input values till pressing enter key

    hi!!!
    i need to enter values thru keyboard using bufer reader etc etc
    but i need to stop entering when i press enter key
    how to do this??

    First off I would take a look at this link because it gives quite a few good examples if you've never used scanner.
    You can find all this on the link.-> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
    in order to use scanner you have to import it.
    import java.util.Scanner;then inside your main method you need to create a scanner wrapped around the keyboard inputstream.
    Scanner userIn = new Scanner(System.in);take a look at the api to decide which method you want. For this I would suggest nextLine().
    also I would specify that you want the numbers separated by spaces or comma's or something so you can use the String.split(" "); method which returns an array of Strings;
    then traverse through the array of strings and convert them to ints
    http://www.rgagnon.com/javadetails/java-0004.html

  • How can i select the next column instead of next row when press enter key

    I need to know how can i select the next column instead of next row when i press the enter key.By default ,when i press enter key the next row is selected and the column remain unchanged but I wants opposite that is the row should remain unchanged but column index will changed.
    Thanks to all.

    Well, the right arrow key will already move you to the next column, so the easiest way to do this is to modify the InputMap to have the Enter key invoke the same Action as the right arrow key.
    You can search the forum for my "Table Actions" (without the space) example that will show you how to do this.

  • How to submit a form by pressing enter key

    Hi,
    I'm having a problem..............i have a form having text field and a button created using struts html tags..........when user enters the value and presses the button then the value is being taken...........
    but if the user enters the data and just presses enter key the form refreshaes but value is not submitted.............
    the button is created using <html:submit >tag.............can any one pls help me out with this???????????

    <script language="JavaScript">
    <!--
    var isNav, isIE
    if (parseInt(navigator.appVersion) >= 4) {
    if (navigator.appName == "Netscape")
    isNav = true
    else
    isIE = true
    function showKeyValue(evt) {
    var keyValue
    if (isNav)
    keyValue = evt.which
    else
    keyValue = window.event.keyCode
    /*status = keyValue*/
    if (keyValue == 13) {
    javascript:validateForm();
    return false
    </script>
    in the field call this method
    onKeyPress="showKeyValue(event)"

  • How to execute code when press the ENTER key

    Hello,
    I've write the code in Key-ENTER trigger, but it doesn't work when I press ENTER key.
    Best Regards
    Joe

    Matth M
    Thank you.
    The following msg. from help system shows that key-enter trigger will execute when the ENTER pressing event occurs. Need your more help.
    Regards
    Joe
    >
    (index: "DO_KEY" )
    Executes the key trigger that corresponds to the specified built-in subprogram. If no such key trigger exists, then the specified subprogram executes. This behavior is analogous to pressing the corresponding function key.
    Built-in............Key Trigger............Associated Function Key
    ENTER............Key-ENTER............[Enter]

  • How to prevent key sound after pressing Enter

    I don't want to hear "beep" sound after pressing enter in TextBox object.
    Is it possible to prevent this?
    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    If e.KeyChar = Convert.ToChar(13) Then
    MsgBox("You will hear "beep" after you press it")
    End If
    End Sub

    Hi,
     I am guessing this is a single line TextBox.  You can use the KeyDown event to detect the Enter key being pressed and Suppress the Key.  If you are using the Enter Key to do something when it is pressed in the TextBox then put it in here
    instead of the KeyPress event.
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    If e.KeyCode = Keys.Enter Then
    e.SuppressKeyPress = True
    'Do something here if you need to when Enter is pressed
    End If
    End Sub
    If you say it can`t be done then i`ll try it

  • Why do I have to press the tab key to edit or enter data in firefox mac? (and how do I turn off this quirk?)

    to enter data in fields in forms and even in the search bar I have to press the tab key. If i do not press tab the silly mac beeps at me and won't let me type. I asked the mac geniuses and they blame firefox, guessing you guys will blame mac... but it is really annoying.

    Hello new_mac_user, see if the next works
    # In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
    # Click '''I'll be careful, I promise!''', to continue to the about:config page.
    # in search field type (or copy/paste from here) '''accessibility.tabfocus'''
    # double-click on it and change the value to '''4''' (probably you have 1 the default on mac)
    # click ok, exit firefox and restart it.
    with the above you give focus to links (and linked images) only when you press the tab key.
    see for more info : http://kb.mozillazine.org/Accessibility.tabfocus
    https://developer.mozilla.org/en-US/docs/Mozilla/Preferences/Preference_reference/accessibility.tabfocus
    thank you

Maybe you are looking for

  • View multiple pages in a script.

    Hello all, In a script , I am  able to see the second page only by giving page numbers(say page 1,page 2) in the goto tab in the output screen. How can I see the second page by clicking F3 or the back button? <<text removed by moderator>> Edited by:

  • BlackMagic Intensity Pro Capture Card & (3) 1TB Internal Hard Drives

    Hello, This is my first time using BM Intensity Pro. Prior to tonight all I used was FW400 & iMovie/iDVD. I have now upgraded to Final Cut Studio with a BM Intensity Pro Capture Card and Three 1TB Hard Drives (7200 RPM with 32MB cache) - Striped as a

  • Problem with my ipod 5g

    lllasss plz help me i have ipod 5g and facetime automatic date and time itunes these things not working now i am in pakistan but i bought ipod from ksa

  • No reconciler was available to process the request.- error

    I was having a problem with reconciliation so I deleted the task and source adapter tasks. When I now attempt incremental reconciliation I know get this error. What do I do now?

  • Hi, I am trying to buy music, yet when I click on the buy button nothing happens.

    Hi I am signed into my itunes account, yet when I go to buy a song nothing happens. I can press down on the button all I want but I don't get any pop up screens asking if I'm sure I want to buy the song or well anything. I've checked my account and t