File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable catching JMeniItem accelerators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable catching JMeniItem accelerators" Watch "JTable catching JMeniItem accelerators" New topic

JTable catching JMeniItem accelerators

Sebastiaan Kortleven
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Hi all,

I've got an editable JTable. When a cell in that table is selected (a normal textfield) and the user uses an accelerator from my menu (eg CTRL-M), the action associated with that accelerated and menuitem is executed, but the editor from the selected cell starts..

Is there a way I can tell the JTable (or the used cell editors) not to respond to CTRL-something ?

I tried adding the KeyEvents to the input map of the JTable (with "none" as action) but that didn't help..

Sebastiaan Kortleven
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
There's also another strange thing happening..

I'm using JTextFields for editing the cells.. but I've overriden the method processFocusEvent so that if the editing starts, all of the text is selected, like this:

This works like a charm when I double click on a cell, or press a singe key (eg D)..
But, when I press a key combination (eg CTRL-D), the event from the JMenuItem associated with this keyevent is started, the cell is being edited, but no text is selected...

this makes me think that there is a different way in how a JTable (or the celleditor handler) handles normal keypresses and combinations..

Anyone who can help me?
I agree. Here's the link:
subject: JTable catching JMeniItem accelerators
It's not a secret anymore!