This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JTable tabbing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JTable tabbing" Watch "JTable tabbing" New topic
Author

JTable tabbing

David A. Scott
Ranch Hand

Joined: Apr 13, 2006
Posts: 55
Hi,

I want to make my main GUI so that it is navigable without the mouse. This means I want to be able to tab across each component on the screen.

However when the JTable component is selected the TAB key causes each individual cell to be selected and then it moves to the next row. When it reaches the last row, it moves back to the top.

Does anyone know how I can override the behaviour so that the TAB key causes the JTable to lose focus and the next component gets focus?

David
Lucy Hummel
Ranch Hand

Joined: Apr 07, 2005
Posts: 232
Hi David,

Your goal sounds pretty good.

But if I were you, I would drop that feature, since


  • the feature is not requested by my assignment
  • more code that might contain a bug
  • more code to document


  • ----------------------------------<br />| SCJP, SCWCD, SCBCD, SCEA, SCJD |<br />----------------------------------
    Maurizio Nagni
    Ranch Hand

    Joined: May 29, 2004
    Posts: 75
    I completely agree with lucy. Like in the real life, and a bit more for the Developer certification always use the KISS rule I try to use it as much as I can

    cheers

    P.S.
    KISS = Keep It Simple Stupid
    David A. Scott
    Ranch Hand

    Joined: Apr 13, 2006
    Posts: 55
    I think an important feature of good GUI design is that you should be able to navigate it without having to remove your hands from the keyboard.

    GUIs which require a bit of typing...followed by mouse click...followed by a bit more typing...followed by a mouse click etc etc... drive me nuts!

    I do accept what you are saying about keeping it simple, and I'm adhering to this philosophy in most other respects!!
    Lucy Hummel
    Ranch Hand

    Joined: Apr 07, 2005
    Posts: 232
    Hi David,

    I totally agree that a GUI should be useable without a mouse and I provide some shortcuts and menubars to reach that goal.

    I know I did not reach this goal fully.
    Arno Reper
    Ranch Hand

    Joined: Mar 14, 2006
    Posts: 286
    Hello,
    My GUI is fully usable only with the keyboard...I'm too lazy so I hate moving to much ( i m a sporting personn, so every movement as to be necessery lool )...every action as a key combo
    Arno


    The man who makes no mistakes does not usually make anything<br /> <br />>>> SCJP 5.0 >> SCJD B&S <<< In progress
    Romeo Son
    Ranch Hand

    Joined: Mar 12, 2007
    Posts: 92

    Hi,

    What if the assesor's computer doesn't have attached a mouse?
    I tried to make my GUI usable only with the keyboard, and I have the same problem, when the focus is captured by my table it doesn't let it go.
    Maybe some answers would be in the Swing area of this forum, but I didn't have the time to check yet, so I was looking with interest this thread.
    Hope somebody will find an answer...


    SCJP 1.4, SCJD, OCE EJBD 6
    Lucy Hummel
    Ranch Hand

    Joined: Apr 07, 2005
    Posts: 232
    Hi Romeo,

    In my opinion:
    If there is a GUI, there is a mouse! Or you have a touch screen.
    Arno Reper
    Ranch Hand

    Joined: Mar 14, 2006
    Posts: 286
    Hello,
    For me it works fine without a mouse...
    You can use tab and mnemonic keys. When you are blocked into the JTable you press "alt+[CHOICE]" and you jump to this component. I did it for the text fields, the buttons, the menus, ...

    @Lucy
    Because its java, I prefered to be sure that my prog could run on the most platform. Even those without a mouse...if I had more time I would do a CLI but its not asked. ( I work under Linux and Mac )
    But I think every approach is right...if you can justify it.

    Do you have news about your submission?
    Arno
    Lucy Hummel
    Ranch Hand

    Joined: Apr 07, 2005
    Posts: 232
    Hi,

    You make me worring so I just add in my assumptions that the architecture assumes that the user has a mouse. Anyway, I also have some mnemonic keys, since I am a fan of vi.

    @Arno
    My submission state... My goal was to upload it today. But my familiy ... I want to get rid of it
    Romeo Son
    Ranch Hand

    Joined: Mar 12, 2007
    Posts: 92

    Thanks all for the replies.
    Arno Reper
    Ranch Hand

    Joined: Mar 14, 2006
    Posts: 286
    A fan of vi woaawww
    Good luck with your family

    Arno
    krishna karthik
    Greenhorn

    Joined: May 06, 2007
    Posts: 1
    hi -

    tabbing inside the jtable will let you move in the table.

    if you want to focus the next focusable component you use Ctrl+Tab key combination. i think that's the default behaviour and shouldn't be changed.

    what do you think?

    thank you.
    David A. Scott
    Ranch Hand

    Joined: Apr 13, 2006
    Posts: 55
    In my application the JTable is only used to present the data and then select a record. There is no real need to TAB between the columns.

    So I'd like to use the TAB key to move onto the next component. I think this would be consistent with most professionally produced gui's.
     
     
    subject: JTable tabbing
     
    Similar Threads
    JTable focus
    JTable and tab order.
    tabbing in JTable
    tabbing in JTable
    JTable Cell and Tab Problem[jdk1.3 ]