Focusing JLable on Tab key..

Hi All,
I have a JFrame that has four text fields and two labels.
basically they are with save and close images acting as the button
for me.
Now my problem is when I press the tab key, the focus transverse
in all four text fields, but it never comes on JLables.
Can anybody tell me how to achieve this.
Hoping for a favorable response
Kind Regards
Chetan Chandarana

Just a guess..
label.setFocusable(true);

Similar Messages

  • 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);
    }

  • Moving the Focus with the TAB key in a JTextArea Component

    Dear Friends,
    I have exhausted all options of moving focus from JTextArea to next component. I have also tried all suggestions available in this forum. But i'm not able to solve my problem. Can any one help me.
    Thanx in advance.

    I had the same problem before. Here is what i did.
    JTextArea txtArea = new JTextArea(2,15);
    Set forwardTraversalKeys = new HashSet();     
    forwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));          
    txtArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,forwardTraversalKeys);          
    Set backwardTraversalKeys = new HashSet();          
    backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));          
    txtArea.setFocusTraversalKeys( KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardTraversalKeys);
    JScrollPane scrollPane = new JScrollPane(
         txtArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    // the scrollbar of the JScrollPane is focusable that's why it requires
    // another TAB key to transfer the focus.
    scrollPane.getVerticalScrollBar().setFocusable(false);

  • Moowing focus with the tab key (swing)

    Hi. I have a JFrame with 4 text areas in. I want to be able to "hop" to the next text area by pressing the tab key. Most internet pages says this is default, but when I press tab, I get a tab space inside the text area I'm in.. Any ideas on how to do this? (i use Java 1.5)

    HashSet focusForward = new HashSet();
    HashSet focusBackward = new HashSet();
    focusForward.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,0));
    focusBackward.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,InputEvent.SHIFT_DOWN_MASK));
        myTextArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,focusForward);
    myTextArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,focusBackward);

  • Customize "Tab" key for JTextArea to focus next component.

    Hi,
    I am trying to change the "TAB" key behaviour for JTextArea, by using CustomAction configured via InputMap() and ActionMap(). When the user presses the Tab key, the focus should go the next component instead of tabbing in the same JTextArea component. Here is the code for the CustomAction().
        public static class CustomTabAction extends AbstractAction {
            private JComponent comp;
            public CustomTabAction (JComponent comp) {
                this.comp = comp;
                this.comp.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "TABPressed");
                this.comp.getActionMap().put("TABPressed", this);
            public void actionPerformed(ActionEvent evt) {
                Object source = evt.getSource();
                if (source instanceof Component) {
                    FocusManager.getCurrentKeyboardFocusManager().
                            focusNextComponent((Component) source);
        }This works for most of the cases in my applicaiton. The problem is that it doesn't work with JTable which has a custom cell editor (JTextArea). In JTextArea field of JTable, if the Tab is pressed, nothing happens and the cursor remains in the custom JTextArea exactly at the same place, without even tabbing spaces. Here is the CustomCellEditor code.
        public class DescColCellEditor extends AbstractCellEditor implements TableCellEditor {
    //prepare the component.
            JComponent comp = new JTextArea();
            public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int rowIndex, int vColIndex) {
                // Configure Tab key to focus to next component
                CustomActions.setCustomAction("CustomTabAction", comp);
                // Configure the component with the specified value
                ((JTextArea)comp).setText((String)value);
                // Return the configured component
                return comp;
            // This method is called when editing is completed.
            // It must return the new value to be stored in the cell.
            public Object getCellEditorValue() {
                return ((JTextArea)comp).getText();
        }regards,
    nirvan

    >
    textArea.getInputMap().remove(....);but that won't work because the binding is actually defined in the parent InputMap. So I think you need to use code like:
    textArea.getInputMap().getParent().remove(...);But I'm not sure about this as I've never tried it.I tried removing the VK_TAB key from both the input map and parent input map as shown below. But I still have to press "TAB" twice in order to get out of the JTextArea column in JTable.
                comp.getInputMap().getParent().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));
                comp.getInputMap().remove(
                            KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));after coding this, I am using the setFocusTraversalKeys for adding only "TAB" key as ForwardTraversalKey as given below.
            Set newForwardKeys = new HashSet();
            newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,newForwardKeys);
            Set newBackwardKeys = new HashSet();
            newBackwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
            comp.setFocusTraversalKeys(
                        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,newBackwardKeys);The only problem that remains now is that I have to press the "TAB" twice in order to get out of the JTextArea column
    regards,
    nirvan.

  • How to use tab key with JTextArea to shift focus

    Hi
    My problem is simple as whenevr i use tab key in my JTextArea, instaed of shifting focus to next component, it adds a tab space to my text.
    How do i shift focus out of my JTextArea.
    Ashish

    you can also redefine the textarea's TAB Key behaviour. The tutorial has a good example for that - better than i would be able to describe :-)
    look at http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html

  • DATAGRID FOCUS ISSUE: Focus got lost, while moving from one cell to another cell using tab key.

    Problem: Focus got lost, while moving from one cell to another cell using tab key.
    Example: In an AdvanceDataGrid, there are three columns having custom ItemRenderer with Spark TextInput control (editable=true & focusEnabled=true).
    When I try to move the focus in with in 2nd, 3rd & 4th column using tab key, focus got lost. Most of the time it’s working, but some time it doesn’t work. There’s no clue as to how may rows/columns the focus has jumped to; or whether the focus has gone out of the data grid altogether.
    Observations: I am not sure whether this problem is because of custom component implementation or it is because of some issue related to Flex Component.
    It only occurs when we perform some actions like some server call, some complex logic execution etc. at the focus out event of itemrenderer.
    There is one property of datagrid i.e. editedItemPosition which contains row & column index of datagrid. On the focus out event, it gets null when focus got lost. We tried to set it, but it didn’t work.
    Steps Performed:-
    1. Currently focus is in 2nd column i.e. Apply to #.
    2. Once I press tab key from 2nd column, it goes to 3rd column which is correct.
    3. Now if I press tab key from 2nd column i.e. Payment #, focus should go to 3rd column, but it goes out of data grid and set the focus of button which is outside data grid.

    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Bjtable+%2Btab+%2B%22enter+key%22&col=javaforums

  • Bringing tab key focus on to SelectManyCheckbox

    Hi,
    Does anyone know if it is possible to be able to tab through the SelectManyCheckbox component items? i.e. just like a user can press the Tab key to move to different InputText components, I would like them to be able to do the same for the SelectManyCheckbox components but by default you are unable to bring focus on to these.
    Thanks

    Hi Frank,
    Thanks for your responsel. I've tried this but it doesn't seem to work. After doing some searching there does seem to be some complicated solutions involving TabIndex and Javascript which could be similar to what I am trying to achieve, but they're not straightforward. I have another page which has only SelectManyCheckbox and on that you can tab through the checkboxes but on the page which also has inputText boxes before/after the SelectManyCheckbox items you can't tab through them.
    Regards

  • How do I use a Tab key to maximize a frame?

    How can I use a Tab key (vk_tab) pressed on the focused frame to actually maximize the frame... what action should it have attached to it?
    thanks!

    tab is the focus traversal key, so will be consumed before getting to your listener
    try this instead
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
         .addKeyEventDispatcher(new KeyEventDispatcher(){
            public boolean dispatchKeyEvent(KeyEvent e){
              if(e.getID() == KeyEvent.KEY_PRESSED)
                if(e.getKeyCode() == KeyEvent.VK_TAB ) f.setExtendedState(JFrame.MAXIMIZED_BOTH);
              return false;
        });

  • In the expression editor dialog box my TAB key doesn't function correctly

    This is bizarre behavior that seems to have started recently.
    In Visual Studio 2012, an SSRS project, any expression editor dialog:
    The tab key doesn't work right.
    Open the expression editor and:
    * I see a blinking cursor and I can type in the expression box.
    * If I hit the tab key, the cursor disappears and I cannot type.  I appear to lose focus in the editor but focus doesn't appear to go anywhere else in the dialog box.
    * If I hit the tab key a 2nd time, the cursor is still gone and I cannot type. 
    * If I hit the tab key a 3rd time, I can finally type again and note that I am now
    3 tabstops in.  In other words it seems like the tabs were working but I lost the ability to type anything until I "tab" 3 magical times. 
    I can work around this by hitting tab key then grabbing the mouse and clicking where the cursor SHOULD be which returns focus to the text area.
    Hopefully this image helps clarify:
    Anybody know what is wrong?
    Microsoft Visual Studio Professional 2012
    Version 11.0.61030.00 Update 4
    Microsoft .NET Framework
    Version 4.5.50709
    Installed Version: Professional
    LightSwitch for Visual Studio 2012   04938-004-0034007-02367
    Microsoft LightSwitch for Visual Studio 2012
    Office Developer Tools   04938-004-0034007-02367
    Microsoft Office Developer Tools
    Team Explorer for Visual Studio 2012   04938-004-0034007-02367
    Microsoft Team Explorer for Visual Studio 2012
    Visual Basic 2012   04938-004-0034007-02367
    Microsoft Visual Basic 2012
    Visual C# 2012   04938-004-0034007-02367
    Microsoft Visual C# 2012
    Visual C++ 2012   04938-004-0034007-02367
    Microsoft Visual C++ 2012
    Visual F# 2012   04938-004-0034007-02367
    Microsoft Visual F# 2012
    Visual Studio 2012 Code Analysis Spell Checker   04938-004-0034007-02367
    Microsoft® Visual Studio® 2012 Code Analysis Spell Checker
    Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.
    The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.
    Visual Studio 2012 SharePoint Developer Tools   04938-004-0034007-02367
    Microsoft Visual Studio 2012 SharePoint Developer Tools
    ASP.NET and Web Tools   2012.3.41009
    Microsoft Web Developer Tools contains the following components:
    Support for creating and opening ASP.NET web projects
    Browser Link: A communication channel between Visual Studio and browsers
    Editor extensions for HTML, CSS, and JavaScript
    Page Inspector: Inspection tool for ASP.NET web projects
    Scaffolding: A framework for building and running code generators
    Server Explorer extensions for Windows Azure Web Sites
    Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Windows Azure
    Color Theme Designer   1.0
    Designer for creating new color themes
    NuGet Package Manager   2.8.50126.400
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
    PreEmptive Analytics Visualizer   1.0
    Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
    SQL Server Analysis Services   
    Microsoft SQL Server Analysis Services Designer 
    Version 11.0.3369.0
    SQL Server Data Tools   11.1.40706.0
    Microsoft SQL Server Data Tools
    SQL Server Integration Services   
    Microsoft SQL Server Integration Services Designer
    Version 11.0.3369.0
    SQL Server Reporting Services   
    Microsoft SQL Server Reporting Services Designers 
    Version 11.0.3369.0
    BIDSHelper
    BIDS Helper 2012 - An add-in to extend SQL Server Data Tools - Business Intelligence (SSDTBI formerly BI Development Studio)
    (c) 2014 Version 1.6.6.0
    http://www.codeplex.com/bidshelper
    SQL Prompt 6
    For more information about SQL Prompt, see the Red Gate website at
    http://www.red-gate.com
    For customer support, call 1-866-733-4283.
    Copyright © 2006–2009 Red Gate Software Ltd

    Hi Bostaevski,
    Thank you for posting in MSDN forum.
    According to your description, as you said that the cursor disappears and cannot type issue. It seems that the issue may be not Visual Studio the VS IDE issue.
    In addition, I find a similar thread about the
    Expression Editor Cursor Issue,
    please see:  
    http://www.beta.microsoft.com/VisualStudio/feedbackdetail/view/780682/vs-2012-rdlc-expression-editor-cursor-issue#.
    Therefore, I suggest you could also try to press alt with left and right arrow keys and check if it is works fine.
    Thnank for your understanding!
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Problem with Tab Key in JFileChooser when Details view is selected.

    Hi all,
    Iam using a JFileChooser in my application.When i click Details option in the JFileChooser the files with the size,Type and modified date are displayed.
    When i am using tab to navigate through the JFileChooser,when the tab enters the area where the files are listed with details,the tab is not comming out of the File List area,instead it is traversing with in the files.How do i come out of the File List area using Tab key.I wanted to make a functionality similar to Windows FileChooser where in if we press Tab it goes to the file list and the next tab focus to Text field and so on.
    Is it possible using JFileChooser??
    Pls Help me,
    Thanks and Regards,
    Ravi

    Hi,
    looking at other threads, I think you will
    have to get the button and modify/remove the tool tip
    as you which.
    this thread might help you, at least the way to get the components in the file
    chooser:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=563002

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

  • [Bug?] How to use the Tab key in forms

    Ahoy!
    The latest release of Photoshop has "broken" the native behavior of the Tab key in html panels. I'm not sure if this is a bug or just a new API I need to incorporate.
    Expected behavior:
    1. Focus into text field in a form
    2. Hit the Tab key
    3. The next field is focused.
    Actual behavior
    1. Focus into text field in a form
    2. Hit the Tab key
    3. Photoshop hides the application UI (Photoshop hotkey tab behavior).
    Anyone happen to know if there's something that can be done about this?

    Bug is very annoying for our users when they try to input their usernames and passwords to login (often) and also when they're filling out a large form with four fields in it.
    Hope it is fixed soon or a work around provided.
    Tom Wrenn
    Frontend Engineer
    CreativeWorx

  • How to recognize the tab key in a JTextField

    I have a drawing program with a main window and a tools palette, which is a JDialog. The tools palette has JToggleButtons and one JTextField. When you have the focus in the JTextField and you press tab repeatedly, it tabs through all the JToggleButtons and then back into the JTextField.
    However I would like to recognize the pressing of the tab key and ask for the focus to go back to the main window.
    I subclassed the JTextField, added a KeyAdapter, but it does not recognize the tab key. I also added the processKeyBinding method, but it doesn't recognize the tab key either.
    How can I recognize the tab key?
    Here is a self-contained test program that illustrates the problem:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AnanyaCurves extends JFrame
      Tools tools;
      public AnanyaCurves(Dimension windowSize)
        Basics.ananyaCurves = this;
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        setTitle("Ananya Curves");
        tools = new Tools(this);
      public static void main(String[] args)
        int toolsWidth;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        toolsWidth = 200;
        Dimension windowSize = new Dimension(screenSize.width - toolsWidth, screenSize.height - 58);
        AnanyaCurves ananyaCurves = new AnanyaCurves(windowSize);
        ananyaCurves.pack();
        ananyaCurves.setBounds(toolsWidth, 0, windowSize.width, windowSize.height);
        ananyaCurves.setVisible(true);
        ananyaCurves.requestFocus();
      public void setVisible(boolean b)
        tools.setVisible(b);
        super.setVisible(b);
    class Basics extends java.lang.Object
      public static AnanyaCurves ananyaCurves;
      public Basics()
    class Tools extends JDialog
      JToggleButton btnGrid;
      JTextField textGrid;
      JPanel panel;
      public Tools(JFrame frame)
        super(frame, "Tools", false);
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        btnGrid = makeBtn("Grid");
        textGrid = makeTextField();
        panel = makePanel();
        pack();
      public JToggleButton makeBtn(String name)
        JToggleButton btn = new JToggleButton();
        btn.setMaximumSize(new Dimension(108, 24));
        btn.setPreferredSize(new Dimension(108, 24));
        btn.setText(name);
        btn.setFont(new Font("Verdana", Font.PLAIN, 11));
        btn.setMargin(new Insets(5, 10, 5, 10));
        btn.setOpaque(true);
        return btn;
      public ACJTextField makeTextField()
        ACJTextField textField = new ACJTextField();
        textField.setFont(new Font("Verdana", Font.PLAIN, 12));
        textField.setMaximumSize(new Dimension(108, 20));
        textField.setPreferredSize(new Dimension(108, 20));
        textField.setText("0.25");
        textField.setEnabled(true);
        return textField;
      public JPanel makePanel()
        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(btnGrid);
        panel.add(textGrid);
        getContentPane().add(panel);
        return panel;
    class ACJTextField extends JTextField
      KeyAdaption keyAdaption;
      public ACJTextField()
        super();
        keyAdaption = new KeyAdaption();
        this.addKeyListener(keyAdaption);
      class KeyAdaption extends KeyAdapter
        public void keyPressed(KeyEvent event)
          int keyCode = event.getKeyCode();
          if (keyCode == KeyEvent.VK_TAB)
            Basics.ananyaCurves.requestFocus();
      protected boolean processKeyBinding(KeyStroke keyStroke, KeyEvent keyEvent, int int2, boolean boolean3)
        int keyCode = keyEvent.getKeyCode();
        if (keyCode == KeyEvent.VK_TAB)
          Basics.ananyaCurves.requestFocus();
          return false;
        return super.processKeyBinding(keyStroke, keyEvent, int2, boolean3);
    }Thanks for looking at this.

    Wow, Michael, you work like magic! Thanks so much! I would be happy to give you a commercial key to my Ananya Curves program also once the second release is on my website. It's a program for drawing curves in an easier way without pulling on tangent lines, with all control points right on the curve. Just send me an email to [email protected] if you are interested!

  • Popup of JComboBox shows on mouseclick but disappears on tab-key

    Hi everybody, I have a DefaultCellEditor with a ComboBox and I want the popup to be visible on focus, so I overwrite the changeSelection method of the JTable as follows:
    public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                super.changeSelection(rowIndex, columnIndex, toggle, extend);
                super.editCellAt(rowIndex, columnIndex);
    } else if (getEditorComponent() instanceof JComboBox) {
                    JComboBox editor = (JComboBox)(getEditorComponent());
                    editor.requestFocusInWindow();
                    editor.showPopup();
                }This behaves like I want it to on mouseclicks. On Tab focus the popup is shown as long as I hold the tab key but disappears again after. What does the release of the Tab key does what the mouse button doesn't and can I change it?
    thanks for aswers

    Classic case of file naming.
    iOS is case-sensitive and requires the name of the file be exactly the same as that used in your code.
    MyImage01.png is not the same as myIMAGE01.PNG
    OS X, and thus the simulator, is not case-sensitive.

Maybe you are looking for

  • HP DV6 Laptop - How do I find my Windows 7 Product Key

    Model:  DV6-1149WM Product:  LW264UAR#ABA I purchased a new hard drive for my laptop.  I want to install a clean version of Windows 7 on this hard drive.  The Windows product key sticker is badly worn on the bottom of my laptop and I can only make ou

  • How do I get my movies from my iTunes library on my old laptop to my new mac pro?

    How do I get my movies from my itune library on my old laptop to my new mac pro?

  • Oracle 9.2.0.8 and AWR report?

    Does anyone know if 9.2.0.8 supports AWR? Thanks in advance!

  • Programmatically creating iBots

    We are use OBIEE to display reports on an external-facing site using an IFrame'd Go URL and would like the ability to notify users by email when a certain report contains data based on a user defined thresholded value (e.g., if sales for a particular

  • Wrong Chq Assigment in FCHU

    Dear All, While assigning the Cheque no. in FCHU the cheque number by mistake has been allotted to a document of other House Bank where as the document was posted with other bank outgoing account. The system does not display any error message and upd