currently i am facing a problem for these method. when my program copying or cutting a selected text and paste to another selected area, unexpected result, it paste the selected text to all of the fields and areas of my program.
is there anyway to check current selected area or maybe there is other way out to solve this problem?

*equipmentArea and area are objects of JTextArea
* the rest are objects of JTextField

MainTabbed mPane = new MainTabbed();
.
.
.
.
 class CopyActionAdapter implements ActionListener{
         UIAFrame adaptee;
         //JTextArea jTextArea = new JTextArea(textArea);
         
          CopyActionAdapter(UIAFrame adaptee){
            this.adaptee = adaptee;
         }
         
          public void actionPerformed( ActionEvent e ) 
         {
            
            mPane.locField.copy();            
            mPane.area.copy();
            mPane.dateField.copy();
            mPane.ndBuddyField.copy();
            mPane.depthField.copy();
            mPane.firstBuddy.copy();
            mPane.weightField.copy();
            mPane.timeInField.copy();
            mPane.tOutField.copy();
            mPane.startTimeField.copy();
            mPane.sTimeField.copy();
            mPane.bTimeField.copy();
            mPane.startField.copy();
            mPane.finishField.copy();
            mPane.airField.copy();
            mPane.surfaceField.copy();
            mPane.bottomField.copy();
            mPane.equipmentArea.copy();
            mPane.waterTypeField.copy();
            mPane.visiField.copy();
            mPane.diveLogField.copy();
            mPane.diveNoField.copy();
         
         }
      }



class PasteActionAdapter implements ActionListener{
         UIAFrame adaptee;
         //JTextArea jTextArea = new JTextArea(textArea);
         
          PasteActionAdapter(UIAFrame adaptee){
            this.adaptee = adaptee;
         }
         
          public void actionPerformed( ActionEvent e ) 
         {
            mPane.area.paste();
            mPane.locField.paste();
            mPane.dateField.paste();
            mPane.ndBuddyField.paste();
            mPane.depthField.paste();
            mPane.firstBuddy.paste();
            mPane.weightField.paste();
            mPane.timeInField.paste();
            mPane.tOutField.paste();
            mPane.startTimeField.paste();
            mPane.sTimeField.paste();
            mPane.bTimeField.paste();
            mPane.startField.paste();
            mPane.finishField.paste();
            mPane.airField.paste();
            mPane.surfaceField.paste();
            mPane.bottomField.paste();
            mPane.equipmentArea.paste();
            mPane.waterTypeField.paste();
            mPane.visiField.paste();
            mPane.diveLogField.paste();
            mPane.diveNoField.paste();
         
         }
      }
Attachments cut.JPG 73.71 KB

Use e.getSource() to determine where to copy / paste to / from rather than mPane.field. For example, your PasteActionAdapter.actionPerformed method should be:

public void actionPerformed(ActionEvent e)
{
  e.getSource().paste();
}

Use e.getSource() to determine where to copy / paste to / from rather than mPane.field. For example, your PasteActionAdapter.actionPerformed method should be:

public void actionPerformed(ActionEvent e)
{
  e.getSource().paste();
}

im sorry to tell u that, it doesn't work :(

---error message---
cannot find symbol
symbol: method paste()
location: class java.lang.Object
e.getSource().paste();

You need to cast e.getSource() to an appropriate type that implements the paste() method.

i've tried that, but the paste() seem not working

((JTextArea)e.getSource()).paste();

This question has already been answered. Start a new discussion instead.