aspose file tools*
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
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
Author

Cut Copy Paste n SelectAll in JTextPane

hema narayan
Greenhorn

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
Bartender

Joined: Oct 18, 2000
Posts: 4121

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


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

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 java.sun.com.......
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..
thanx
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

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":
http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JTextPane.html
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:
http://www.jalice.net/textfaq.htm
(Look for "Cut/copy/paste")
http://developer.java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html#JFCJTextAction
http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html
Good Luck,
Avi.
 
jQuery in Action, 2nd edition
 
subject: Cut Copy Paste n SelectAll in JTextPane
 
Similar Threads
Need to restrict ctrl+c, ctrl+v, ctrl+x
Error - ; expected
JMenuItems tricks for displaying short cut text
Help With JTabbed Pane
disabling windows paste for text components