m.itern(i).addActionListener(this);
}
setSize(300,300);
show;
}
public void actionPerformed(ActionEvent evt){
if("Paste".equals(evt.getActionCommand)){
boolean error=true;
Transferable t=
getToolkit.getSystemClipboard.getContents
(this);
try{
if(t! =nullt.isDataFlavorSupported(Dat-
aFlavor.stringFlavor)){
textArea.setBackground(Color.white);
textArea.setForeground(Color.black);
textArea.replaceRange(
(String)t.getTransferData(DataFlavor.stringFla-
vor),
textArea.getSelectionStart,
textArea.getSelectionEnd);
error=false;
}
}catch(UnsupportedFlavorException e){
}catch(IOException e){
}
if(error){
textArea.setBackground(Color.red);
textArea.setForeground(Color.white);
textArea.repaint;
textArea.setText("ERROR:\nEither the clip-
board"+"is empty or the contents is not fl string.");
}
}else if("Copy".equals(evt.getActionCommand
)) {
setContents;
}else if("Cut".equals(evt.getActionCommand
)){
setContents;
textArea.replaceRange("",textArea.getSelec-
tionStart,textArea.getSelectionEnd);
}
}
void setContents{
S=textArea.getSelectedText;
St ringSelection contents = new StringSelection
(s);
getToolkit.getSystemClipboard.setContents
(contents,this);
}
public void lostOwnership(Clipboard clipboard,
Transferable contents){
System.out.println("lost ownership");
}
public static void main(String args[]){
new java3;
}
}