This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Cut Copy Paste n SelectAll in JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Cut Copy Paste n SelectAll in JTextPane" Watch "Cut Copy Paste n SelectAll in JTextPane" New topic

Cut Copy Paste n SelectAll in JTextPane

hema narayan

Joined: Dec 28, 2001
Posts: 6
i want to implement cut, copy, paste n select all option for JTextPane........
By using this statement below.....
Clipboard clipbd = Toolkit.getDefaultToolkit().getSystemClipboard()
these operations r getting implemented through..
Ctrl-X, Ctrl-C, Ctrl-V, Ctrl-A...
but my problem is how to implement them through ActionListener.....
that is when a user clicks the buttons of cut, copy, paste...n select..etc..
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

You would just call the cut(), copy(), and paste() methods of your JTextPane in the action listener...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
hema narayan

Joined: Dec 28, 2001
Posts: 6
i am glad to receive a reply to my query but i am very sory to say that i am not able to find any such methods of cut(), copy(), paste(), selectall()
in JTextPane....i have also looked into the site of
may be that thing has got slipped off by me..
then it is requested to plz clear ur point with specifying some example.....telling how to implement it..
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Hi Hema,
Excuse me, but I didn't see what JDK version you are using -- sorry. However, if you are using version 1.2 (or above), the javadoc for class "javax.swing.JTextPane":
states that the "copy()", "cut()" and "paste()" methods are inherited from class "javax.swing.text.JTextComponent".
If you are looking for some examples of how to use these methods, perhaps the following URLs will help you:
(Look for "Cut/copy/paste")
Good Luck,
I agree. Here's the link:
subject: Cut Copy Paste n SelectAll in JTextPane