• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Cut Copy Paste n SelectAll in JTextPane

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This tiny ad is suggesting that maybe she should go play in traffic.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic