• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Another JTable Navigation Question

 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
If a column in a "JTable" has zero width, it is not visible,
as demonstrated in below code snippet:

However, when using the keyboard navigation keys, like TAB, to navigate
the "JTable" cells, the invisible cell still receives the focus.
When an invisible cell has the focus, there is no visual indication of this
and the user has no idea why suddenly no cell of the table is selected.
My question is: What is a recommended way of ensuring that invisible columns
in a "JTable" do not receive input focus?

Thanks,
Avi.
[ November 04, 2008: Message edited by: Avi Abrami ]
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Avi Abrami:

My question is: What is a recommended way of ensuring that invisible columns
in a "JTable" do not receive input focus?
[ November 04, 2008: Message edited by: Avi Abrami ]



Remove the column instead of hiding it by making it 0 width.
In case you do not know how to remove columns, search the forums. There are quite a few recent threads which will tell you how to do it.
 
Avi Abrami
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maneesh,
You said:


Remove the column instead of hiding it by making it 0 width.


Oops, forgot to mention the obvious (to me, anyway :-)
This is not my application, I am just maintaining it.
At this stage, the invisible columns are required and used by the application so removing them is not currently an option.
Hence the question ;-)
Thanks anyway for your prompt and nonetheless helpful reply.

Cheers,
Avi.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try tracking the focus.
If your "undesired" column gains focus, you can shift the focus on the previous/next column.
 
Avi Abrami
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maneesh,
Thanks again for your help.
Please pardon my ignorance, but how does one "track the focus"?
I assume I need to add a focus listener, or is there another way?
Method "addFocusListener" is defined in class java.awt.Component.
So which "Component" should I add the focus listener to, since "JTable" is a complex GUI control that involves many different "Component"s.

Also, there appears to be several ways to "shift the focus".
I am hoping that someone reading this will be able to recommend a preferred way of doing this.

Thanks,
Avi.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you aware of the "Renderer" concept? Usually you define a Renderer for a Column.
The getTableCellRendererComponent() method returns a Component.
So one of the possible ways is to add a focus listener to the renderer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic