我开发的 eclipse splash 插件有一个奇怪的问题。它是一个非矩形窗口,我使用 shell.setRegion ()
来定义多边形。
这在 Windows 机器上完美运行,但在 macOS High Sierra 中显示空白屏幕。
这是缩小版,减少到真正影响的几行。
它在 eclipse 启动时显示一个简单的三角形作为初始屏幕。
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.splashHandlers">
<splashHandler
class="CustomSplash2"
id="splashHandler">
</splashHandler>
<splashHandlerProductBinding
productId="org.eclipse.platform.ide"
splashId="splashHandler">
</splashHandlerProductBinding>
</extension>
</plugin>
飞溅处理器
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.splash.BasicSplashHandler;
public class CustomSplash2 extends BasicSplashHandler {
public CustomSplash2() {
super();
}
@Override
public void init(final Shell splash) {
super.init(splash);
FillLayout layout = new FillLayout();
splash.setLayout(layout);
Region region = new Region();
region.add(new int[] { 0, 200, 100, 0, 200, 200 });
splash.setRegion(region);
splash.setSize(region.getBounds().width, region.getBounds().height);
}
}
eclipse 版本:Neon.3
最佳答案
这看起来是 macOS 版本的 Shell
中的一个问题,如果设置了区域但未设置背景颜色,则不会绘制背景图像。
只需设置 Shell
背景颜色似乎就可以解决这个问题并使图像出现。
splash.setBackground(splash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
问题出在Shell.drawBackground
方法
关于java - SWT Shell setRegion 在 macOS 中的 Eclipse 启动中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52276772/