From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/clpbrd.inc | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc') diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc b/Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc new file mode 100644 index 0000000..94e2e53 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc @@ -0,0 +1,33 @@ +/* clpbrd.inc */ + +public void actionPerformed(ActionEvent event) +{ + Clipboard clip = getToolkit().getSystemClipboard(); + String cmd = event.getActionCommand(); + if (cmd.equals("Kopieren")) { + String s = "Es ist " + System.currentTimeMillis() + "Uhr"; + StringSelection cont = new StringSelection(s); + clip.setContents(cont, this); + } else if (cmd.equals("Einfuegen")) { + Transferable cont = clip.getContents(this); + if (cont == null) { + System.out.println("Zwischenablage ist leer"); + } else { + try { + String s = (String) cont.getTransferData( + DataFlavor.stringFlavor + ); + System.out.println(s); + } catch (Exception e) { + System.out.println( + "Zwischenablage enthält keinen Text" + ); + } + } + } +} + +public void lostOwnership(Clipboard clip, Transferable cont) +{ + System.out.println("Inhalt der Zwischenablage ersetzt"); +} \ No newline at end of file -- cgit v1.2.3