Results 1 to 6 of 6
- 04-15-2009, 09:39 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 7
- Rep Power
- 0
[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?
- 04-15-2009, 10:15 PM #2
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...
- 04-16-2009, 12:29 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 7
- Rep Power
- 0
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?
- 04-16-2009, 01:32 AM #4
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...
- 04-17-2009, 12:43 AM #5
Member
- Join Date
- Apr 2009
- Posts
- 7
- Rep Power
- 0
So simple once it's accomplished. Thank you again, you have been a great help. :)
- 04-17-2009, 12:56 AM #6
Similar Threads
-
Can't turn on breadcrumbs in enclipse
By Jubei1980 in forum EclipseReplies: 0Last Post: 11-24-2008, 10:08 PM -
Turn off sounds in Eclipse
By gio.fou in forum EclipseReplies: 2Last Post: 09-06-2008, 08:31 PM -
how can i turn this java program to an applet
By anotsu in forum New To JavaReplies: 5Last Post: 03-10-2008, 11:48 PM -
turn off auto compile
By bugger in forum EclipseReplies: 3Last Post: 01-04-2008, 08:12 PM -
To turn a view jsp to a pdf file
By Daniel in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-05-2007, 06:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks