diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/clpbrd.inc | 33 |
1 files changed, 33 insertions, 0 deletions
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 |
