我正在尝试为Mac上的SWT Cocoa端口创建一个NSPopover。Here是在Objective-C中实现的方法,但我想知道如何使用SWT实现相同的功能。Popover如下所示:

SWT的可可端口中没有'NSPopover‘,接口中不存在。
我如何创建它?
发布于 2018-02-06 19:43:53
您可以尝试如下所示:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class PopOver {
public static void main(String[] a) {
Display display = new Display();
final Shell shell = new Shell(display,SWT.NO_TRIM);
Region region = new Region();
region.add(new Rectangle(0,0,200,200));
region.add(new int[]{200,90,220,100,200,110});
shell.setRegion(region);
shell.setSize(region.getBounds().width, region.getBounds().height);
shell.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}这就是结果:

https://stackoverflow.com/questions/47168058
复制相似问题