Results 1 to 4 of 4
  1. #1
    fam2315 is offline Member
    Join Date
    Feb 2011
    Posts
    78
    Rep Power
    0

    Default FocusTraversalPolicy in Swing

    Is it possibly to explicitly define a tab order with the FocusTraversalPolicy, by specifying with buttonNames which button comes before/after the next button, or do you have to define it with an algorithm? For instance:

    Java Code:
    JPanel mainPanel contains:
                      JPanel panel1 contains:
                               JButton1, JButton2, JButton3
                      JPanel panel2 contains:
                                JTableA, JButton 4, JButton 5
    Can I say something like Tab in this order:

    JButton1, JButton2, JButton3, JTableA, JButton4, JButton5, back to JButton1. I'm not able to see how that would work with a JTable though, or does each Panel have its own traversal policy that takes over once it gains focus? What would happen when I tab to the last row/last column of the JTable? I'm seeing it jump back to the top of the table and start over, so it seems like this could be complicated.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    There is a lot of this covered in the API doc and in the Tutorial.
    Have you read them?
    Java Platform SE 6

  3. #3
    fam2315 is offline Member
    Join Date
    Feb 2011
    Posts
    78
    Rep Power
    0

    Default

    yea, I've looked at some of it and a few examples, I just can't seem to get a handle on the whole nesting issue. From what I've seen, with a JTable at least, once I am tabbing through it, when I get to the bottom, it goes back to the first row/column and starts traversing again. Also, I have panels inside panels, so I wasn't sure if I would declare a traversal policy for each of those subPanels, or just the main container, and then it would handle the traversal once I jump to a new panel.

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    The Tabbing functionality of a JTable is handled by a custom Action that is used by the table, not the focus traversal policy.

    If you your requirment it to tab to the next next component when you reach the end of the table then you will need to replace the existing Action with a custom tabbing Action. Check out: Table Tabbing Java Tips Weblog for an example to get your started.

Similar Threads

  1. First day of Swing
    By Grish in forum New To Java
    Replies: 10
    Last Post: 06-02-2011, 01:02 PM
  2. FocusTraversalPolicy
    By Lil_Aziz1 in forum New To Java
    Replies: 6
    Last Post: 07-22-2010, 03:28 PM
  3. Swing
    By tmotse in forum AWT / Swing
    Replies: 0
    Last Post: 03-31-2010, 10:18 AM
  4. where is the swing jar?
    By katie in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 10:58 PM
  5. map javax.swing.text.Element to javax.swing.text.View
    By elizabeth in forum New To Java
    Replies: 1
    Last Post: 07-30-2007, 07:02 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
  •