title: Java: Right Click Copy Cut Paste On TextField
body: <p>I've made a program which prints a value in a text field. The problem is that when a user right clicks in the text field, a menu like this won't open:</p>
  
  <p><img src="https://i.stack.imgur.com/BI9Pv.png" alt="enter image description here"> 
  <br/></p>
  
  <p>Is there a way the user can have this menu open upon right click?
  <br/></p>
  
  <p>This is my code:</p>
  
  <pre><code>public class A extends JFrame{
  private JTextField txt1;
  private JTextField txt2;
  private JLabel val;
  private JLabel prt;
  private JButton bt1;
  
  
      public A() {
  
      getContentPane().setLayout(null);
  
      txt1 = new JTextField();
      txt1.setBounds(178, 93, 87, 28);
      getContentPane().add(txt1);
  
  
      txt2 = new JTextField();
      txt2.setBounds(178, 148, 87, 28);
      getContentPane().add(txt2);
  
  
      val = new JLabel("Enter Value");
      val.setBounds(84, 93, 69, 28);
      getContentPane().add(val);
  
      prt = new JLabel("Printed Value");
      prt.setBounds(80, 148, 87, 28);
      getContentPane().add(prt);
  
  
  
      bt1 = new JButton("Click This");
      bt1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
  
          int n=Integer.parseInt(txt1.getText());
          txt2.setText(n+"");
  
  
          }
      });
      bt1.setBounds(178, 188, 105, 28);
      getContentPane().add(bt1);
  
          setSize(400, 399);
          setResizable(false);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLocationRelativeTo(null);
          setVisible(true);   
  
      }
  }
  </code></pre>
  
  <p>Main Method:</p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args) {
  
  
          A object = new A(); 
      }
  
  }
  </code></pre>