• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cut/Copy/Paste from JTextField?

 
Matt Hazan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am fairly new to Java programming and I was wondering if someone can help me figure out how to use the JTextComponent cut(), paste(), etc... tools.

My program has text fields that appear in a JFrame... I also have an Edit menu where the user could copy, paste, and cut the text in the selected text in the textfield area.

What I tried to do is simply use myField.cut(); (which should work, i think), However, this does not work. I am not getting an error or a warning, it compiles and runs fine, however when I try to cut the text in the program it does not respond, the text remains as if I never tried to 'cut'.


Any help will be greatly appreciated!

Thanks in advance!
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post an SSCCE that demonstrates the problem.
 
Rob Camick
Ranch Hand
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The section from the Swing tutorial on Text Component Features shows you how to implement copy/cut/paste using the Actions defined in the Editor Kit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic