Sender.java



import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;

/** ButtonAndTextクラスを拡張した Senderクラス */

public class Sender extends ButtonAndText implements ClipboardOwner{

   /** 使用するクリップボード */

      public Clipboard clip;

   /** コンストラクタ */

      Sender( Clipboard clip ) {
       
            super( "Input and Copy", "Copy" );
            this.clip = clip;
      }

   /** アクション処理のメソッド */

      public void actionPerformed( ActionEvent evt ){

            StringSelection ss 
              = new StringSelection( textArea.getText() );
            clip.setContents( ss, this );
      }

   /** クリップボードの権限を失った時の処理 */

      public void lostOwnership( Clipboard cli, Transferable tra ){
      }
}