
// letzte Aenderung: 23.10.2010

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.lang.*;




public class Clipboard01 extends JFrame  {
  JToolBar toolBar = new JToolBar();
  JButton BnCopy = new JButton("Copy to Clipboard");
  JButton BnCut = new JButton("Cut to Clipboard");
  JButton BnPaste = new JButton("Paste from Clipboard");

  JTextArea editor = new JTextArea("Dies ist eine Zeile\r\nDies ist die 2. Zeile");

  public Clipboard01() {
    this.setSize( 600, 300);
    this.setTitle("Beispiel über die Zwischenablage");
    this.setLocation(100,100);
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

  public void setGUI() {

    BnCopy.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        BnCopy_click();
      }
    });
    toolBar.add(BnCopy);
    toolBar.addSeparator( new Dimension(20,5) );

    BnCut.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        BnCut_click();
      }
    });
    toolBar.add(BnCut);

    toolBar.addSeparator( new Dimension(20,5) );

    BnPaste.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        BnPaste_click();
      }
    });
    toolBar.add(BnPaste);


    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    JScrollPane sc = new JScrollPane(editor);
    this.getContentPane().add(sc, BorderLayout.CENTER);
    editor.setFont( new Font("Arial", Font.BOLD,18)  );

  }


  private void BnCopy_click() {
    editor.copy();
  }

  private void BnCut_click() {
    editor.cut();
  }

  private void BnPaste_click() {
    editor.paste();
  }



  public static void main(String[] args) {
    Clipboard01 frame = new Clipboard01();
    frame.setVisible(true);
  }

} // Clipboard01


