I have a subclass of ChartPanel and I want it to respond when the user types
a backspace by reverting the chart to a previous state. How do I go about
making the chart respond to backspace?
My first idea was to override createPopupMenu from ChartPanel and add a
new item "Back" to that menu, and then put an accelerator key on that item.
I got the item to work ok: it appears in the menu and if you choose it, it
runs my action.
Then I wrote:
Code: Select all
char backspace = KeyEvent.VK_BACK_SPACE;
item.setAccelerator(KeyStroke.getKeyStroke(backspace));
any other character either.
Do I have to turn on the capability to respond to accelerator keys
somewhere?
Is there a better way to do this? I don't care whether the
command is on the popup menu or not; I just want it to respond to
the keystroke. I could perhaps live with another key if it turns out
that Backspace [ascii 8] is a problem in some way.
Thanks
Jim Goodwin