I wrote the code to copy something to the clipboard in Kotlin.
Environment
- Java 10.0.2
- macOS High Sierra 10.13.6
- Kotlin 1.3.0
Code
It is similar to Java, because I used Java classes.
1 2 3 4 5 |
import java.awt.Toolkit import java.awt.datatransfer.StringSelection val clipboard = Toolkit.getDefaultToolkit().systemClipboard clipboard.setContents(StringSelection("data"), null) |
Speaking about setContents
method, second parameter represents “owner”.
java.awt
“awt” represents “Abstract Window Toolkit”. It is Java’s original platform-dependent windowing, graphics, and user-interface widget toolkit. The AWT is part of the Java Foundation Classes (JFC), which is the standard API for providing a graphical user interface for a Java program. AWT is also the GUI toolkit for a number of Java ME profiles.
Java ME is used in resource restricted devices, such as mobile phone, micro controller, sensor.
Comparing to Swing, AWS is fast, light weight.