I put this in my actionPerformed method.  Don't know if it's the best
way, but it works for all of my components that have the key stroke
mapped.

public void actionPerformed(ActionEvent evt) {
    JComponent focusComponent =
(JComponent)SwingUtilities.findFocusOwner(MyClass.this);
    if (focusComponent == null)
        return;

    Object key = focusComponent.getInputMap().get(
    KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    if (key != null)
        focusComponent.getActionMap().get(key).actionPerformed(evt);
}

--- Keith Bennett <[EMAIL PROTECTED]> wrote:
> Dear Swingers, ;->
> 
> I sent this message out on the regular Swing list yesterday, but
> realized
> this is a rather advanced question, so I'm posting it here.  Thanks
> for any
> help you can offer.
> 
> We're writing an app that has an Edit menu containing items for Cut,
> Copy,
> Paste, Select All, etc.
> 
> I know Swing already has functionality corresponding to these tasks
> because
> when the appropriate key is pressed (ctrl-x, c, v, a, respectively),
> the
> right thing happens.
> 
> How can I get access to these actions so I can attach them to my menu
> items?
> 
> I know DefaultEditorKit has public static classes for cut, copy, and
> paste,
> and some others.  However, SelectAll, among others, is an inner class
> that
> is not public, so I can't access it from a subclass outside of its
> package.
> 
> What is the best way to get to this functionality?  For example, is
> there a
> way to "stuff" the appropriate key into a key input buffer?


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to