选之前,照例看看大牛们的选择。
stackoverflow上的大牛几年前的文章
知乎上的选择
其实也没什么好选的。
SWT 就是他了,至于为什么。我就是要个最简单的程序,能截屏,能模拟鼠标和键盘,不喜欢AWT,好吧就这么简单。
1. 加入Swt的类库
2. 写个测试
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class TestSwt {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello world");
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
- 结果成功
大功告成!
Yeah!