SWT在不同的系统上 [英] SWT on different systems

查看:89
本文介绍了SWT在不同的系统上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java和SWT的Browser.我准备了两个系统版本的应用程序,第一个用于OSX,第二个用于Windows.

I used Java and SWT's Browser. I prepare two system versions of application, first for OSX second for Windows.

两个系统均为64位

SWT对于不同的系统需要不同的库,因此在Maven中我声明了两者

SWT need different libraries for different systems so in Maven I declared both

<profile>
    <id>windows-deploy</id>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.swt</groupId>
            <artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
            <version>4.6.1</version>
        </dependency>
    </dependencies>
</profile>

<profile>
    <id>osx-deploy</id>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.swt</groupId>
            <artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
            <version>4.6.1</version>
        </dependency>
    </dependencies>
</profile>

在浏览器中,我加载页面并单击按钮(这将创建新窗口),但我不想打开新窗口,仅重新加载实际的浏览器中的新页面,就像下面的代码一样

In the browser I load page and click button (which creates new window) but I do not want open new window, only reload actual browser which new page, I did it like in code below

browser.addOpenWindowListener(new OpenWindowListener() {
    public void open(WindowEvent event) {
        Log.debug(TAG + "<>", "Open new page!");
        event.browser = browser;
    }
 });

在OS X系统上,它运行良好.

And on OS X system it works great.

但是当我在Windows上尝试时,单击按钮的旧页面后不会更改.我检查了日志和消息打开新页面!"已被写入,但没有任何反应(新页面不会像OS X那样加载).我虽然可以说是有关WebKit加载页面后刷新和browser.refresh()刷新浏览器的信息,但是内容很旧(在OS X中不是新内容).

But when I try on Windows, after click on button old page do not change. I checked Logs and the message "Open new page!" was written but nothing happens (new page do not load like in OS X). I though that can be something about refreshing after load page by WebKit and browser.refresh() refresh browser but there is old content (not new like in OS X).

我调试并检查了event.browser = browser;来自SWT库的WebKit取得控制权之后会发生什么.

I debug and checked what happens after event.browser = browser; the WebKit from SWT library take control.

我应该怎么做才能在Windows上获得与OS X一样的效果?

What I should do to get the same effect on Windows like on OS X ?

推荐答案

已解决

问题在库中.在OSX系统上,当我们更改event.browser对象时,会自动检测到它并且可以正常工作,但是在Windows系统上,我们需要将其添加到浏览器VisibilityWindowListener中,如下面的代码片段所示,并且可以正常工作:)

Problem is in libraries. On OSX system when we change event.browser object, is automatically detected and it working, but on Windows system we need to add to browser VisibilityWindowListener as in code fragment below and working fine :)

browser.addVisibilityWindowListener(new VisibilityWindowListener() {
            public void hide(WindowEvent event) {
            }

            public void show(WindowEvent event) {
                Browser browser = (Browser) event.widget;
                Shell shell = browser.getShell();

                if (event.location != null)
                    shell.setLocation(event.location);

                if (event.size != null) {
                    Point size = event.size;
                    shell.setSize(shell.computeSize(size.x, size.y));
                }

                shell.open();
            }
        });

这篇关于SWT在不同的系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆