Results 1 to 6 of 6
  1. #1
    Angie is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Question [SOLVED] How do you turn off Tab and Back Tab in JTable?

    In a JTable when user presses Tab or Shift + Tab the focus moves from cell to cell (either forward or backward).
    Is there a way to turn off the Tab and Shift + Tab key in the table? I would like for only the Up Arrow and Down Arrow keys to be recognized.

    Also, is it possible to make it so that a mouse click on a cell does not make the cell aware but rather makes the entire line aware?

  2. #2
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    There are probably several ways to do this, but I like to use Key Bindings when I want to control the actions of keys... Check out:

    How to Use Key Bindings (The Java™ Tutorials )

    If you get stuck, post your questions...

    As for the second part of your question... I am not sure what you mean by aware...
    Who Cares... As Long As It Works...

  3. #3
    Angie is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Smile Thank You!

    I used

    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCU SED_COMPONENT).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "none");
    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCU SED_COMPONENT).put(
    KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), "none");

    and it works like a charm.

    I find the second part of my question difficult to explain but I'll try: When I mouse click on a cell in the table, the cell gains focus in the sense that a bold border is drawn around it (even though the cell is not editable). I don't want it to do that because the idea is that you can only select a row, not a specific cell. Does that make sense?

  4. #4
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    Yes it does... You want to create a custom Cell Renderer... Google it... There is tons of info out there... Let me know if you get stuck...
    Who Cares... As Long As It Works...

  5. #5
    Angie is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Thumbs up

    So simple once it's accomplished. Thank you again, you have been a great help. :)

  6. #6
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

Similar Threads

  1. Can't turn on breadcrumbs in enclipse
    By Jubei1980 in forum Eclipse
    Replies: 0
    Last Post: 11-24-2008, 11:08 PM
  2. Turn off sounds in Eclipse
    By gio.fou in forum Eclipse
    Replies: 2
    Last Post: 09-06-2008, 09:31 PM
  3. how can i turn this java program to an applet
    By anotsu in forum New To Java
    Replies: 5
    Last Post: 03-11-2008, 12:48 AM
  4. turn off auto compile
    By bugger in forum Eclipse
    Replies: 3
    Last Post: 01-04-2008, 09:12 PM
  5. To turn a view jsp to a pdf file
    By Daniel in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 07:23 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
  •