我的尝试如下,没有提出任何结果:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Image image = new Image(display,
"D:/topic.png");
GC gc = new GC(image);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawText("I've been drawn on",0,0,true);
gc.dispose();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
// TODO Auto-generated method stub
}
最佳答案:
Shell shell = new Shell (display);
Label label = new Label (shell, SWT.BORDER);
label.setImage (image);
标签:java,swt
来源: https://codeday.me/bug/20190515/1110019.html
本文提供了一个使用Java SWT库进行图像绘制的例子,展示了如何加载图片资源并使用GC对象在其上绘制文字。
243

被折叠的 条评论
为什么被折叠?



