public class ClipboardUtil extends Object
Constructor and Description |
---|
ClipboardUtil() |
Modifier and Type | Method and Description |
---|---|
static Object |
get(DataFlavor flavor)
获取剪贴板内容
|
static Object |
get(Transferable content,
DataFlavor flavor)
获取剪贴板内容
|
static Clipboard |
getClipboard()
获取系统剪贴板
|
static Image |
getImage()
从剪贴板获取图片
|
static Image |
getImage(Transferable content)
从剪贴板的
Transferable 获取图片 |
static String |
getStr()
从剪贴板获取文本
|
static String |
getStr(Transferable content)
从剪贴板的
Transferable 获取文本 |
static void |
listen(ClipboardListener listener)
监听剪贴板修改事件
|
static void |
listen(ClipboardListener listener,
boolean sync)
监听剪贴板修改事件
|
static void |
listen(int tryCount,
long delay,
ClipboardListener listener,
boolean sync)
监听剪贴板修改事件
|
static void |
set(Transferable contents)
设置内容到剪贴板
|
static void |
set(Transferable contents,
ClipboardOwner owner)
设置内容到剪贴板
|
static void |
setImage(Image image)
设置图片到剪贴板
|
static void |
setStr(String text)
设置字符串文本到剪贴板
|
public static void set(Transferable contents)
contents
- 内容public static void set(Transferable contents, ClipboardOwner owner)
contents
- 内容owner
- 所有者public static Object get(DataFlavor flavor)
flavor
- 数据元信息,标识数据类型public static Object get(Transferable content, DataFlavor flavor)
content
- Transferable
flavor
- 数据元信息,标识数据类型public static void setStr(String text)
text
- 字符串文本public static String getStr()
public static String getStr(Transferable content)
Transferable
获取文本content
- Transferable
public static void setImage(Image image)
image
- 图像public static Image getImage(Transferable content)
Transferable
获取图片content
- Transferable
public static void listen(ClipboardListener listener)
listener
- 监听处理接口ClipboardMonitor.listen(boolean)
public static void listen(ClipboardListener listener, boolean sync)
listener
- 监听处理接口sync
- 是否同步阻塞ClipboardMonitor.listen(boolean)
public static void listen(int tryCount, long delay, ClipboardListener listener, boolean sync)
tryCount
- 尝试获取剪贴板内容的次数delay
- 响应延迟,当从第二次开始,延迟一定毫秒数等待剪贴板可以获取listener
- 监听处理接口sync
- 是否同步阻塞ClipboardMonitor.listen(boolean)
Copyright © 2024. All rights reserved.