Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cut Copy Paste n SelectAll in JTextPane

 
hema narayan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would just call the cut(), copy(), and paste() methods of your JTextPane in the action listener...
 
hema narayan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic