我开发的eclipse splash插件有一个奇怪的问题。它是一个非矩形窗口,我使用shell.setRegion ()定义了多边形。

这在Windows机器上可以完美运行,但是在macOS High Sierra中显示空白屏幕。

这是缩小版本,减少到只有几行真正影响。

在日食启动时,它显示了一个简单的三角形作为启动屏幕。

java - SWT Shell setRegion在macOS的Eclipse Splash中不起作用-LMLPHP

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>


SplashHandler

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);
    }
}


月食版:Neon.3

最佳答案

Shell的macOS版本中,这似乎是一个问题,如果设置了区域且未设置背景色,则不会绘制背景图像。

仅设置Shell背景色似乎可以解决此问题并使图像显示。

splash.setBackground(splash.getDisplay().getSystemColor(SWT.COLOR_WHITE));


问题出在Shell.drawBackground方法中

10-05 21:12
查看更多