Cut « JTextField « Java Swing Q&A





1. Global context menu for Cut/Copy/Paste with JTextField in Swing App?    stackoverflow.com

What is the best way to implement a global default context menu for a Swing app that has the Windows-standard cut/copy/paste/etc. popup menu for things like JTextField? Tim Boudreau suggested installing ...

2. Cut/Copy/Paste from JTextField?    coderanch.com

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 ...

3. cut/copy/paste in JTextField    java-forums.org

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Assign1 implements ActionListener { JFrame fr; JTextField tf; JButton b1,b2,b3; Assign1() { fr=new JFrame(); fr.setLayout(null); tf=new JTextField(); b1=new JButton("cut"); b2=new JButton("copy"); b3=new JButton("paste"); tf.setBounds(20,35,200,30); b1.setBounds(20,80,55,50); b2.setBounds(80,80,65,50); b3.setBounds(160,80,75,50); fr.add(b1); fr.add(b2); fr.add(b3); fr.add(tf); fr.setSize(250,250); fr.setVisible(true); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent arg0) { [B]tf.setSelectionStart(5); tf.setSelectionEnd(10); tf.cut(); tf=new JTextField(); tf.copy(); tf=new JTextField(); ...