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.

Similar Messages

  • Enter key press instead of tab key

    I want to use enter key Instead of tab key in my page to move to next item
    Please answer in detail steps because i am new to apex and especially to Javascript

    I strongly advice against using an app like this.
    I always play by the rule not to re-invent the wheel.
    Try to convince the user from the new possibilities and the fact that tabbing is a default procedure.
    You'll see that this will be easier than actually programming the enter-key to act like the TAB key.
    I you really need to do this, then you'll need to do something like this
    http://thinksimply.com/blog/jquery-enter-tab
    good luck!
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Shouldn't this Enter Key do same as Tab key?

    I am trying to have the Enter key switch the focus between these 2 JTextField. (like the Tab key), but I can't get it to work.
    Any advice, please?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class TestGUI extends JFrame{
         JPanel panel = new JPanel();
         JTextField field01 = new JTextField("Test 1");
         JTextField field02 = new JTextField("Test 2");
         TestGUI(){
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              panel.add(field01);
              panel.add(field02);
              getContentPane().add(panel);
              field01.setBounds  (125,120,23, 50);
              field02.setBounds  (100,120,23, 50);          
              setBounds(200,50, 300, 300);
              KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
              KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
              InputMap im = field01.getInputMap(JTextField.WHEN_FOCUSED);
              im.put(enter, im.get(tab));
              addWindowListener(new WindowAdapter() {
                   public void windowActivated(WindowEvent e) {
                        field01.requestFocusInWindow();
              setVisible(true);
         public static void main (String[] args){
              new TestGUI();
         

    But how could I get rid of the warning for unchecked operations, when I am compiling it?
    Set<AWTKeyStroke> keystrokes = new HashSet<AWTKeyStroke>();And if you have more than two fields on the panel which all should react to <Return>, use setFocusTraversalKeys(...) once for the panel; there's no need to attach it to each field.
    And there's no need to add a windowListener to place the cursor. Just put the line
    field01.requestFocusInWindow();after setVisible(true);

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

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

  • The correct approach to intercept TAB key

    Dear Experts,
    I have developed a GUI out of javax.swing. The GUI consists of JFrame, several JPanels and javax components, such as JTextField, JLabel, JComboBox, JTable and many more.
    Now, I want to change the behavior when user presses TAB key. By default TAB key moves focus from a component to another component. How can I disable this?
    I come to two alternatives that I am not sure which one is the correct approach. Could you please advise me?
    Alternative 1.
    Use key binding on GlassPane.
    Alternative 2.
    Use event-handling on GlassPane.
    If those alternatives are not the best one, could you please provide another alternative?
    I have tried the following, but they didn't work...
    Action doNothing = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Tab-key is pressed.");
    cmbPCode.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    cmbPCode.getActionMap().put("doNothing", doNothing);or
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    getRootPane().getActionMap().put("doNothing", doNothing);where cmbPCode is a JComboBox that receives focus when the GUI shows up.
    Thanks for your help,
    Patrick
    Edited by: Patrick_Stiady on Mar 31, 2009 6:51 AM

    Thank you for the advice. I am developing an application where the user is not computer literated, so that I have to limit functional key as many as possible and only allow several keys to be active. For example, I don't want TAB key to change the focus, instead I want TAB key to do nothing.
    I have tried keybinding, because I think this is the most relevant, but somehow I failed to recognize which component should be bound with keybinding. I have tried to change the input map of the component that receives the focus when the GUI is displayed (cmbPCode) as can be seen on my first post. I also tried to change the input map of the root pane. Both are not successful.
    Now, I wonder whether
    1. it does not work because the key is not consume()?
    2. Or should I use key listener, which I would only use if keybinding were unable to serve my goal?
    3. Or should I learn how to intercept key on the glass pane?
    4. Is keybinding able to nullify default action, such as changing focus by TAB key? I am asking this, because I'm going to nullify other important key such as ENTER key.
    Thank you for any guidance,
    Patrick

  • Tab Key in Word not indenting lists!?

    So, all of a sudden when I create a list in Word the Tab key and the Shift + Tab key combo no longer indent/dedent items in a list.
    I've tried:
    - Both of the "Full Keyboard Access" modes in Keyboard and Mouse. Not like this should effect what goes on in Word, but gave it a shot.
    - Resetting the PRAM (doing command + option + p + r)
    Note This works normally in other accounts on the system. Only on my account is the tab key behaving this way.
    Anything else I should attempt?

    you cannot do that in ABAP...
    you have to set your fields on screen according to the sequence

  • How to supress tab key stopping at lables

    Hi everyone,
    after upgrading to 5.0 from 4.02 and changing the theme to 26 (productivity), there is now a problem with the tab key.
    Before, the tab key moved the entry scope simply to the next dialog field or list value; now the tab stops also at the labels.
    That means, to skip from one entry field to the next, you have to press tab twice.
    How can I change this back to the old way ?

    Norbert W. wrote:
    thank you for your response. I came from theme no.2 (Builder blue). I´ve tested this case with Firefox and Chrome (actual versions). The label templates are mostly "Optional with help", "Optional" and "Required with help".
    Now I found that "optional" is working as expected (without tabstop), while the others are producing stops.
    This is happening because the "with help" label templates contain links for displaying item-level help, and they therefore receive focus when using keyboard navigation. This is actually good accessibility practice, and you are recommended to retain it. Changing labels so they don't use "with help" templates where there is no help is also appropriate.
    The workaround used to avoid this standard behaviour in theme 2 is to include a tabindex attribute with a sequence number higher than the possible number of page items on the help links:
    <label for="#CURRENT_ITEM_NAME#" id="#LABEL_ID#" tabindex="999"><a class="optional-w-help" href="javascript:apex.theme.popupFieldHelp('#CURRENT_ITEM_ID#','&SESSION.')" tabindex="999">
    You could revert to this behaviour by editing the theme 26 "with help" label templates to include the tabindex:
    <label for="#CURRENT_ITEM_NAME#" id="#LABEL_ID#" class="uOptional"><a class="uHelpLink" href="javascript:apex.theme.popupFieldHelp('#CURRENT_ITEM_ID#','&SESSION.')" tabindex="999">

  • HT201236 my 'tab' key stopped working. I would like to assign a different key to replace it. is that possible?

    thanks!!

    Thanks for your replies.
    It is definite, according to my testings, that there is a hardware problem with the keyboard.
    i am looking for a way to assign a different key or combination of keys, instead of the 'tab' key.
    Illaass- I would rather find a way, within apples system to do this, rather than playing around with the system files... thanks

  • Make Enter key act like Tab Key

    Is there any way to make pressing the Enter key change the focus to the next field in the tab order? In other words, make the Enter and Tab keys act the same way?
    Thanks!
    Nelson

    Hitting [Enter] key triggers "exit" event, so add the following code appropriately xfa.host.setFocus(TabTo); where 'TabTo' is the field name to set the focus. However you do need to match with the tabbing order in the form just to make sure [Enter] and [Tab] keys function similarly.
    SekharN

  • Enter key to act like tab key in JTable

    I have programmed a JTable application. I want that if I press 'Enter' key in the JTable cell, the cell at right side may be selected after validating input. Similarly, when I press 'Enter' in the right most cell, the first cell of the next row may be selected after validating input.
    In other words, I like 'Enter' key to behave as forward navigational key in JTable cells like 'Tab' key, however, after validating input.
    The following is the piece of code which is not working for me. Though, it changes selection border to the next cell on pressing enter, but the focus is not shifted and editing remains in the current cell.
    //voucherTable is a JTable object with three columns.
    Action moveForward = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
    int r=voucherTable.getSelectedRow();
    int c=voucherTable.getSelectedColumn();
    if(c==2){
    c=-1;
    r+=1;
    voucherTable.changeSelection(r,c+1,false,false);
    voucherTable.getInputMap().put(KeyStroke.getKeyStroke
    (KeyEvent.VK_ENTER,0),"moveForward");
    voucherTable.getActionMap().put("moveForward",
    moveForward);
    Kindly advise me to solve the problem.
    Thanks.
    Mujjahid

    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    im.put(enter, im.get(tab));

  • JButton gains focus when Hitting tab key but hitting Enter has no effect.

    Hi,
    I have a program that has two buttons. When pressed, using the mouse, the buttons text appears in the middle of the screen. I have NOT alerted the focus subsystem. Thus when I press the tab key the buttons are highlighted in turn, to indicate that they currently have focus. However if I press enter the buttons actions (to update the middle of the screen with it's text) does not get activated.
    I am using 1.4.2 on a Windows machine.
    any help on this would be much appreciated !!
    The code is as follows:
    package com.logicacmg.skynet.tms.mmi.ui;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import java.awt.Container;
    public class Test implements ActionListener
    JButton bTwo = new JButton("button 2");
    JButton b = new JButton("button 1");
    JLabel label = new JLabel(" ");
    /** Creates a new instance of Test */
    public Test()
    JFrame frame = new JFrame();
    //Create a panel to hold the MMI screens.
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    b.addActionListener(this);
    bTwo.addActionListener(this);
    mainPanel.add(b, BorderLayout.WEST);
    mainPanel.add(bTwo, BorderLayout.EAST);
    mainPanel.add(label, BorderLayout.CENTER);
    //add the main panel which contains the screens and the status bar
    //to this frame.
    Container contentPane = frame.getContentPane();
         contentPane.add(mainPanel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
    public static void main(String [] args)
    new Test();
    public void actionPerformed(ActionEvent e)
    JButton aButton = (JButton)e.getSource();
    if(aButton == b)
    label.setText("one");
    else if(aButton == bTwo)
    label.setText("Two");

    Which plaf are you using? Because when I switch to the windows plaf, the behavior is what you describe.
    Demo:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) {
            final JFrame f = new JFrame("button focus");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    System.out.println(evt.getActionCommand());
            Container cp = f.getContentPane();
            cp.setLayout(new FlowLayout());
            for(int i=0; i<3; ++i) {
                JButton btn = new JButton("Button " + i);
                btn.addActionListener(al);
                cp.add(btn);
                if (i == 1)
                    f.getRootPane().setDefaultButton(btn);
            final JCheckBox laf = new JCheckBox("platform plaf");
            laf.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent evt) {
                    String cls = laf.isSelected() ? UIManager.getSystemLookAndFeelClassName() :
                      UIManager.getCrossPlatformLookAndFeelClassName();
                    try {
                        UIManager.setLookAndFeel(cls);
                        SwingUtilities.updateComponentTreeUI(f);
                    } catch (Exception e) {
                        e.printStackTrace();
            cp.add(laf);
            f.pack();
            f.setVisible(true);
    }

  • Enter and tab keys no longer work

    Good morning.
    My enter and tab keys are no longer working within a text box. Could it be the result of installing "Deke Shortcuts" on my system? I never had a problem before the installation....
    Any suggestions would be welcome.
    Thank you.

    Did you try removing the shortcuts?
    I'd suggest resetting your prefes: Adobe InDesign CS4 * Setting preferences

  • 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

Maybe you are looking for

  • How to print from a Mac to a PC by WiFi

    I have a printer (Canon MF6530)  connected to a PC Windows XP ServicePack3, i want to know, how can i print from my mac (MacBook Black Intel Core 2 Duo(/Lion)) to the PC by using WiFi, i´ve been trying several times, made my research and cant make it

  • Table in Designer 8

    Is it possible to insert a table with say 4 columns and 4 rows into a form while have different column widths on each row. Example; Row1 Column1(Size 1") -Row1 Column2(Size 1") - Row1 Column3(Size 1") Row2 Column1(Size 1/2") -Row2 Column2(Size 1 1/2"

  • Fourth generation iPad keeps restarting itself randomly

    My brand new fourth generation iPad (Wi-Fi+Cellular, 32 GB) keeps restarting itself randomly. I did the iTunes restoring procedure 2 times, the second one I also delete completely everything from the device before, in order to install the iOS 6.1 on

  • Putting stuff on while downloading

    If I'm downloading a TV show from iTunes, could I put a TV show I already downloaded onto my iPod at the same time?

  • I accidentally removed all my blocked cookies - can I restore them somehow?

    I was adding the name of a website to block in privacy settings/ cookies/exceptions and hit the remove all websites key accidentally. Was the list saved somewhere so it can be restored?