Basic clipboard use with JTextAreas?

M

Mark Space

Hi all. I'm having some trouble find the exact documentation I need so
I thought I'd ask here.

I'd like to bind a simple menu selection like Edit -> Copy to the
clipboard copy command. I'm using standard JTextField's and
JTextArea's. Cut, copy and paste already work via accelerators with out
any intervention from me. So how do I just tell the current focused
component that the user just selected a menu instead of the pressed the
accelerator key?

Since cut, copy and paste already are implemented it seems like there
should be a simple way of binding a menu to the existing mechanism. Any
examples I've found in the Java Tutorial on Sun's site talk about
implementing a child of the AbstractAction class and providing a lot of
functionality, which I don't really need right now. What I'd really
like to do is just tell the whole frame that the user want's to copy and
let the existing system figure it out:

getRootPane().doACopy();

Do I really need to find the current focused component, determine if
it's a cut/copy/paste capable Component, and then call the method
myself? This seems pretty involved. Surely there's an easier way.

Thanks in advance for any help you can provide!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top