java - SWT Shell setRegion 在 macOS 中的 Eclipse 启动中不起作用

标签 java eclipse-plugin swt

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

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

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

它在 eclipse 启动时显示一个简单的三角形作为初始屏幕。

enter image description here

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/

相关文章:

java - DELPHI中如何将JObject转换为TJavaArray<byte>

java - 在 ubuntu 14.04 中安装 sql developer 4 时出错

Java Runtime.exec 转义字符串中的参数

java - Eclipse 的代码标准(非样式)执行器

java - 如何在 Eclipse 插件上动态或更新名称?

Java语法错误: The method Foo is undefined for the type Bar

eclipse - 如何从build.xml文件构建hadoop1.0.4 eclipse插件?

java - 使用 SWT 创建 GUI 时出现 Event.gc 错误

java - SWT 表 - 复选框/突出显示监听器

java - 以编程方式从菜单栏中打开菜单(以编程方式模拟菜单单击以进行 UI 自动化测试)