Results 1 to 8 of 8
  1. #1
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default [SOLVED] Navigate with Cursor keys

    Hello Everyone,

    is there anything like a TabIndex in a JDialog?. I want to navigate with my cursor keys through the TextFields of my mask (JDialog) but I cant find JDialog.TabIndex or anything like this. What can I use to do this?

    Thx for suggestions

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    As far as I know there is an automatic order to set the index. It's, automatic indexing are added from left to right and from top to bottom order. I never seen any other way to change this.

  3. #3
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default

    mhm, does that mean it is not possible?!?

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    No way, there is a solution. But you have to be careful to use it.

    Java Code:
    FocusTraversalPolicy()

  5. #5
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default

    ah ok, i will look at this. Thank you

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Ya, have a try and see. It's not difficult at all. Set the order from one to the other in the order you want. Just like indexing.

  7. #7
    hannehomuth's Avatar
    hannehomuth is offline Member
    Join Date
    Jul 2008
    Location
    Sommerfeld (Brandenburg, Germany)
    Posts
    36
    Rep Power
    0

    Default

    Oh thats not what I wanted, the Indexorder is correct, but I can only naviagte with TAB and SHIFT+TAB. And I wanted to navigate with SHIFT + TAB, TAB and with Cursor UP, Cursor DOWN. But you send me in the right Direction. It works with.

    Java Code:
    public class AddContactView extends javax.swing.JFrame {
    ...
    ...
    ...
        public AddContactView() {
            initComponents();
            contact = new Contact();
            Set<AWTKeyStroke> forwardKeys = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
            Set<AWTKeyStroke> backwardKeys = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
            Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(forwardKeys);
            Set<AWTKeyStroke> newBackwardKeys = new HashSet<AWTKeyStroke>(backwardKeys);
            newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
            newBackwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0));
        
            this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys);
            this.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, newBackwardKeys);
        }
    
    ...
    ...
    ...
    Thank you very much!!!
    Last edited by hannehomuth; 07-25-2008 at 12:17 PM. Reason: Forgot something

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. How to Hide cursor
    By priya in forum Java Software
    Replies: 1
    Last Post: 12-09-2010, 09:39 PM
  2. Replies: 0
    Last Post: 07-11-2008, 03:07 PM
  3. Cursor
    By serfster in forum New To Java
    Replies: 2
    Last Post: 06-15-2008, 05:49 AM
  4. GUI cursor change problem
    By ludragon in forum Advanced Java
    Replies: 2
    Last Post: 01-09-2008, 10:03 PM
  5. Using a cursor
    By notnumber6 in forum New To Java
    Replies: 3
    Last Post: 11-26-2007, 10:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •